Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

TRUNC(SYSDATE) and SYSDATE IN WHERE CLAUSE

javed555Jul 18 2017 — edited Jul 18 2017

Hi,

Can someone explain why the second last select statement returns 2 rows whereas last select statement returns only on row?

drop table t1;

create table t1 (row_id number, startdate date, enddate date);

insert into t1 values(1,trunc(sysdate), to_date('2020-01-01','yyyy-mm-dd'));

insert into t1 values(2,sysdate, to_date('2020-01-01','yyyy-mm-dd'));

select * from t1 where sysdate between startdate and enddate;

select * from t1 where trunc(sysdate) between startdate and enddate;

Thanks,

Javed

This post has been answered by Frank Kulash on Jul 18 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 15 2017
Added on Jul 18 2017
2 comments
3,741 views