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: date column select question

Re: date column select question

From: Thomas Gaines <Thomas.Gaines_at_noaa.gov>
Date: Thu, 08 Aug 2002 17:32:54 -0600
Message-ID: <3D52FFA5.F7578C70@noaa.gov>


Ralf -

Yes, there is an easier way. Check out the truncate function when applied to dates. Do this little query on your end, and you should see how to apply it to your situation:

select to_char(sysdate,'mm/dd/yyyy hh24:mi:ss'),

       to_char(trunc(sysdate),'mm/dd/yyyy hh24:mi:ss') from dual;

Pretty neat, huh? You'll see that this function eliminates the time portion of the Oracle date column, allowing one to easily compare just dates and ignore times.

Tom

Ralph Snart wrote:

> ok this is really dumb, and i would think it's also a faq,
> although all the faq references i have seen only deal
> with inserts and not selects.
>
> i've been mainly using mysql lately so my oracle knowledge
> has totally dried up.
>
> how do i select a specific date from a date column?
>
> select * from table where date='05-AUG-02'
>
> returns nothing even though there are rows with that
> date. the only way i can get it to work is to do this
> horrible construction:
>
> select * from table where
> date BETWEEN TO_DATE('08/05/2002 00:00:00', 'MM/DD/YYYY HH24:MI:SS')
> AND TO_DATE('08/06/2002 00:00:00', 'MM/DD/YYYY HH24:MI:SS')
>
> there's got to be a simpler way...
>
> -rs-
Received on Thu Aug 08 2002 - 18:32:54 CDT

Original text of this message

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