Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: sysdate & date columns
If you are sure you date1 has hour:minute:second set to 00:00:00
select * from table1 where date1=trunc(sysdate); will always be the best.
If date1 has not hour:minute:second set to 00:00:00
If date1 is not indexed, this will work fine :
select * from table1 where trunc(date1)=trunc(sysdate);
If date1 is indexed, using the trunc function will cause the index not to work, so :
select * from table1 where date1 >= trunc(sysdate) and date1 < trunc(sysdate)+1;
is preferable if your table statistics are up todate (analyze table table1 estimate statistics) and your optimizer mode is statistics.
Larry Pettit <larry.pettit_at_ps.net> a écrit dans l'article
<YTrh4.134$j4.7687_at_news.uswest.net>...
>
> This doesn't work.
>
> select * from table1 where date1 = sysdate
> Is there a way to compare a date column with sysdate other than
> converting both using to_char()?
>
> I think the time part of the date is causing this not to work, any
> suggestions?
>
> Thanks
>
>
>
Received on Thu Jan 20 2000 - 03:58:40 CST
![]() |
![]() |