Connecting Tech Pros Worldwide Forums | Help | Site Map

DATE function problems

Corky
Guest
 
Posts: n/a
#1: Nov 12 '05
This works:

db2 SELECT DISTINCT PROBLEM_OBJECTS.PROBLEM_ID FROM PROBLEM_OBJECTS
INNER JOIN PROBLEMS ON PROBLEM_OBJECTS.PROBLEM_ID =
PROBLEMS.PROBLEM_ID WHERE INTEGER(DAYS(CURRENT DATE) -
DAYS(PROBLEMS.CLOSE_DATE)) = 365 AND PROBLEMS.CLOSE_DATE IS NOT NULL

But this doesn't:

db2 SELECT DISTINCT PROBLEM_OBJECTS.PROBLEM_ID FROM PROBLEM_OBJECTS
INNER JOIN PROBLEMS ON PROBLEM_OBJECTS.PROBLEM_ID =
PROBLEMS.PROBLEM_ID WHERE INTEGER(DAYS(CURRENT DATE) -
DAYS(PROBLEMS.CLOSE_DATE)) > 365 AND PROBLEMS.CLOSE_DATE IS NOT NULL

The only difference is the comparison operator ( = vs. > )

Any ideas?

Thanks in advance,

Corky

Mark A
Guest
 
Posts: n/a
#2: Nov 12 '05

re: DATE function problems


"Corky" <mowere@konicabt.com> wrote in message
news:7e5571df.0312031235.122888c5@posting.google.c om...[color=blue]
> This works:
>
> db2 SELECT DISTINCT PROBLEM_OBJECTS.PROBLEM_ID FROM PROBLEM_OBJECTS
> INNER JOIN PROBLEMS ON PROBLEM_OBJECTS.PROBLEM_ID =
> PROBLEMS.PROBLEM_ID WHERE INTEGER(DAYS(CURRENT DATE) -
> DAYS(PROBLEMS.CLOSE_DATE)) = 365 AND PROBLEMS.CLOSE_DATE IS NOT NULL
>
> But this doesn't:
>
> db2 SELECT DISTINCT PROBLEM_OBJECTS.PROBLEM_ID FROM PROBLEM_OBJECTS
> INNER JOIN PROBLEMS ON PROBLEM_OBJECTS.PROBLEM_ID =
> PROBLEMS.PROBLEM_ID WHERE INTEGER(DAYS(CURRENT DATE) -
> DAYS(PROBLEMS.CLOSE_DATE)) > 365 AND PROBLEMS.CLOSE_DATE IS NOT NULL
>
> The only difference is the comparison operator ( = vs. > )
>
> Any ideas?
>
> Thanks in advance,
>
> Corky[/color]

I don't know the answer to your question, but I don't understand why you are
using the integer function since the days function returns the value in
integer format.

When you say "does not work." Does that mean you get an error or no data
returned.


Serge Rielau
Guest
 
Posts: n/a
#3: Nov 12 '05

re: DATE function problems


You working on some Mars-Probe? On Earth 365 is pretty much all you get
in a year....

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab

Mark A
Guest
 
Posts: n/a
#4: Nov 12 '05

re: DATE function problems


"Serge Rielau" <srielau@ca.eye-bee-m.com> wrote in message
news:bqltme$jij$2@hanover.torolab.ibm.com...[color=blue]
> You working on some Mars-Probe? On Earth 365 is pretty much all you get
> in a year....
>
> Cheers
> Serge
> --
> Serge Rielau
> DB2 SQL Compiler Development
> IBM Toronto Lab
>[/color]
What about leap years?


Serge Rielau
Guest
 
Posts: n/a
#5: Nov 12 '05

re: DATE function problems


Hmmm, I just had this one backfire on me, eh?


--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab

Knut Stolze
Guest
 
Posts: n/a
#6: Nov 12 '05

re: DATE function problems


Mark A <ma@switchboard.net> wrote:
[color=blue]
> "Serge Rielau" <srielau@ca.eye-bee-m.com> wrote in message
> news:bqltme$jij$2@hanover.torolab.ibm.com...[color=green]
>> You working on some Mars-Probe? On Earth 365 is pretty much all you get
>> in a year....
>>[/color]
> What about leap years?[/color]

And don't forget that there is more than just one year...

Anyway, what is the exact error message that is returned by DB2 on the "not
working" query?

--
Knut Stolze
Information Integration
IBM Germany / University of Jena
Closed Thread