Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Date comparison question.

Re: Date comparison question.

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Thu, 21 May 1998 01:12:29 GMT
Message-ID: <35637f3b.2768801@192.86.155.100>


A copy of this was sent to Michael Rothwell <michael_rothwell_at_non-hp-usa-om46.om.hp.com> (if that email address didn't require changing) On Wed, 20 May 1998 15:40:24 -0700, you 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
>

sysdate-13 has a time component, your function workday.getday may or maynot. You'll want to compare

decode( trunc(sysdate-13), trunc(workday.getday(5)), 1, 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.
 

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Herndon VA  

http://govt.us.oracle.com/ -- downloadable utilities  



Opinions are mine and do not necessarily reflect those of Oracle Corporation  

Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Wed May 20 1998 - 20:12:29 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US