Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: How to compare a datetime field to a Date
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