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!

date and equality predicate

905989Nov 23 2012 — edited Nov 23 2012
Hi gurus,

I would like to use a date column in a query by equating it to cerain day.

For example, I created a table with date column (eff_date as date) and added the following dates
create table testme (eff_date date not null)

 insert into testme values (sysdate);

insert into testme values (trunc(sysdate));

insert into testme values (sysdate-1);

 select * from testme;

EFF_DATE
-------------------
23/11/2012 21:31:16
23/11/2012 00:00:00
22/11/2012 21:32:35

select * from testme where eff_date = '23/11/2012';

EFF_DATE
-------------------
23/11/2012 00:00:00

select * from testme where eff_date > '23/11/2012';

EFF_DATE
-------------------
23/11/2012 21:31:16

 select * from testme where eff_date >= '23/11/2012'

EFF_DATE
-------------------
23/11/2012 21:31:16
23/11/2012 00:00:00
So in the code above the equality predicate eff_date = '23/11/2012' only displays the exact value at start of day? If I wanted all entries for today I will have to do
select * from testme where eff_date between '23/11/2012' and '24/11/2012' order by 1;

EFF_DATE
-------------------
23/11/2012 00:00:00
23/11/2012 21:31:16
Is my understanding correct?

Thanks
This post has been answered by Frank Kulash on Nov 23 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 21 2012
Added on Nov 23 2012
5 comments
563 views