Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: date column select question
Daniel,
Isn't it better to use a 'screwy' format and then specify what the format
is to TO_DATE, then to figure out the format for the instance (it is my
understanding that the format can be set different for each instance
installed on the same machine, not to mention from machine to machine) and
then have to remember why it works on one site and not another?
"Daniel Morgan" <damorgan_at_exesolutions.com> wrote in message
news:3D566FF0.717522BC_at_exesolutions.com...
>
> You are making one common mistake, one classic.
>
> Try this:
>
> SELECT *
> FROM table
> WHERE TRUNC(date_field) = TO_DATE('08-AUG-2002');
>
> Always use TO_DATE
> Always use TRUNC to set the hours, minutes, and seconds to 00:00:00
> And TO_DATE don't write screwy dates in TO_DATE and then reformat them.
> Just use the valid format in the first place.
>
> Daniel Morgan
>
Received on Mon Aug 12 2002 - 07:49:39 CDT