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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Birthday Query

Re: Birthday Query

From: Brian Tkatch <SPAMBLOCK.Maxwell_Smart_at_ThePentagon.com.SPAMBLOCK>
Date: Mon, 22 Oct 2001 14:46:55 GMT
Message-ID: <3bd4307b.947328343@news.alt.net>


On Mon, 22 Oct 2001 01:59:44 GMT, Ed Prochak <edprochak_at_magicinterface.com> wrote:
>
>Assuming Birthday is a DATE type field, why didn't you try this?
>
>select * from test
>where birthday between sysdate-15 and sysdate+15;

Unless I need to know about newborns, or am clairvoyant, this won't work. :-)

Birthdays are given with a year. I need to know about their birthday *this* year.

>Handles leapyears and everything fine. ORACLE treats dates as units of
>days for numberical calculations. You don't even need the "and birthday
>IS NOT NULL".
>Try it.

The NOT NULL is required to handle the conversion when the date is NULL. Otherwise, when using TO_DATE it'll complain. But, yes, if I did not need to use TO_DATE, I could remove that clause.

>
>At worst you may want to do a truncate() on the dates to make them all
>relative to the same time of day. I'll leave that as an exercise for the
>reader.

I never even thought of that.

>
>And yes the WHERE clause is effectively precessed bottom up.
>
>Enjoy.

Brian Received on Mon Oct 22 2001 - 09:46:55 CDT

Original text of this message

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