I have a table with date column. But when I use the '>' operator the result set returned is not as expected.
select * from table where birth_day > '10-jan-2020';
expected result set should not have 10-jan-2020 value as in query '>' is used. But in result set I am seeing 10-jan-2020,11-jan-2020... Is this how sql behaves?
Try this:
select * from table where birth_day >= to_date('2020.01.11', 'yyyy.mm.dd');
In oracle, Date
datatype stores time too.
so you have multiple options to fetch result as follows:
select * from table where birth_day >= date '2020-01-10' + 1;
-- all the birth_day having date >= 2020-01-10 00:00:00 will be included
select * from table where trunc(birth_day) > date '2020-01-10';
-- trunc(birth_day) will trunc the date to starting of the day - 00:00:00
-- so it will work without adding one day to your date '2020-01-10'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.