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: How to compare a datetime field to a Date

Re: How to compare a datetime field to a Date

From: Hans Forbrich <news.hans_at_telus.net>
Date: Tue, 19 Oct 2004 15:07:58 GMT
Message-ID: <i5add.17060$_u6.2835@edtnps89>


md9_at_ibest.com.br wrote:

> HI I would like to do something like this
>
> Select * from table where date(datettiemfield)= TO_DATE('10/18/2004')
>
> I want the hour to be ignored in the comparison.
>
> Regards,
> Marcello Dias

You are probably looking for the 'TRUNC' function - according to the manual "If you omit fmt, then date is truncated to the nearest day."

Date manipulation can be tricky and deserves a bit of attention, especially now that we have several new date & time related types. Strongly suggest you spend a bit of time in the SQL Reference manual, in which chapter 1 discusses the data type and some date arithmetic basics, and chapter 6 looks at the functions.

http://docs.oracle.com will lead you there, and specificaly for 9iR2 go to http://www.oracle.com/pls/db92/db92.homepage Received on Tue Oct 19 2004 - 10:07:58 CDT

Original text of this message

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