Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Client and Server SQL statements work differently??
>Is it something like
> where sampledate <= To_date('31-12-98')
No, you have to supply the date format. Oracle does not store dates as strings, but as some kind of numeric value, containing both date and time.
In
SELECT *
FROM psms_db.down_hist
WHERE datestamp > '06-Aug-1998 00:00:00'
you do not use to_date. But the column datestamp has been defined as a date column. To be able to compare a date to a string, Oracle will first convert the string to a date, using the default date format. Also, Oracle uses that default date format when you use to_date(..) but do not specify the date format. You can see what your default date format is by:
select sysdate
from dual;
Here, no to_char(..) is explicitly specified, but Oracle will implicitly convert sysdate to a string anyway, using the default date format. So, you will have to use:
SELECT *
FROM psms_db.down_hist
WHERE datestamp > to_date( '06-Aug-1998 00:00:00', 'DD-Mon-YYYY
HH24:MI:SS' );
or, when the time part is 00:00:00
WHERE datestamp > to_date( '06-Aug-1998', 'DD-Mon-YYYY' );
Arjan. Received on Thu Aug 06 1998 - 13:26:14 CDT
![]() |
![]() |