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: to_date function

Re: to_date function

From: Andy <as.no.spam.stedat_at_gmx.net>
Date: Tue, 18 Dec 2001 08:28:03 GMT
Message-ID: <3c1efbda.946663279@by-news.bayer-ag.com>


On Tue, 18 Dec 2001 13:46:09 +0800, "Katak" <kahtat_at_yahoo.com> wrote:

>dear all
>
>I am having difficulty selecting records based on dates. Can anyone help?
>
>I tried using
>select * from tableA where created_date = to_date('15/12/01', 'dd/mm/yy');
>
>though i have records in the database. i do not get any results executing
>the above mentioned SQL code. anyone can lend a hand on this????? thanks
>
>
>
>

Because to_date(...) results in a date AND time component your query will fail except for those rows which have exactly set created_date to 15/12/01 00:00:00 (time component at midnight.

Try ... where trunc(created_date) =
trunc(to_date('15/12/01','dd/mm/yy');

To avoid any Y2K discrepancies you should use instead 4 digit years. Itīs at least better readable ;-)

hth
Andy Received on Tue Dec 18 2001 - 02:28:03 CST

Original text of this message

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