Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: How to compare a date to sysdate
ramdan wrote
>SQL> SELECT SYSDATE FROM DUAL;
An Oracle data always includes the time as well.
As you do not specify a print format, Oracle prints it using the default format which happend to be dd-mon-yyyy in your case. However, printing is only done in the very final stage of your query. In the where clause, the dates still have the time part, and you would be very lucky to have an exact match.
select to_char(sysdate, 'dd-Mon-yyyy hh24:mi:ss') , to_char( trunc(sysdate), 'dd-Mon-yyyy hh24:mi:ss') from dual;
>select * from tab1row
>where readdate = (select sysdate from dual);
Like shown above, use trunc(my_date) to set the time part to midnight, 0:00:00
select *
from tab1row
where trunc(readdate) = trunc(sysdate);
Note that no subquery is needed to use sysdate.
Arjan. Received on Tue Mar 02 1999 - 16:05:53 CST
![]() |
![]() |