Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Date comparison question.
The contents of the type DATE is more then Month/Day and Year. It also
contains hour, minute and second. Your default date format forces the
database to convert your date without hour, minute and second, so it works.
In general your program should use explizit format models like
to_date('12-3-98', 'MM-DD-YY') so that you're independent of the
default date format which can change an all your programs won't work any
longer.
In article <35635BD8.6024B890_at_non-hp-usa-om46.om.hp.com>,
michael_rothwell_at_non-hp-usa-om46.om.hp.com wrote:
>
> I have a function workday.getday(nn) that returns a date.
>
> For instance: select workday.getday(5) from dual
> returns 07-MAY-98
>
> Today 5/20/98 if I: select sysdate - 13 from dual
> it also returns 07-MAY-98
>
> if I use DECODE to test the equivalence of these two dates
> it returns a false code.
>
> select decode( sysdate-13, workday.getday( 5 ), 1, 0 ) from
> dual
> returns 0
>
> but if I convert from date to CHAR it works returns a true
> code.
>
> select decode( to_char( sysdate-13, 'YYMMDD' ),
> to_char( workday.getday( 5 ), 'YYMMDD' ), 1,
> 0 )
> from dual
> returns 1
>
> Why does the comparison not work when both are left in date
> format?
>
> Michael.
>
-----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/ Now offering spam-free web-based newsreading Received on Fri May 22 1998 - 01:17:16 CDT
![]() |
![]() |