Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Oracle Timestamp
Faby wrote:
> Hi,
> I was wondering how I should convert a timestamp to compare it to
> '01-AUG-2006'.
>
> Is any of the following right?
>
> TO_CHAR(TRUNC(MYTIMESTAMP)) < '01-AUG-2006'
>
> TO_DATE(TRUNC(MYTIMESTAMP)) < '01-AUG-2006'
>
> TO_CHAR(MYTIMESTAMP,'DD-MON-YYYY') < '01-AUG-2006'
>
> If you could give a brief explaination of why I am getting a different
> result for each of the previous answer, i would really appreciate.
>
If you want to compare timestamps, compare timestamps, not strings. :)
TRUNC(MYTIMESTAMP) < TO_DATE('01-AUG-2006', fmt_string)
Btw. Do you have TIMESTAMPs, or DATEs? (Though I guess it doesn't make a difference in this case.)
best,
Martin
Received on Thu Aug 10 2006 - 04:56:26 CDT