Oracle comparing timestamp with date
oracle
Solution
You can truncate the date part:
select * from table1 where trunc(field1) = to_date('2012-01-01', 'YYYY-MM-DD')
The trouble with this approach is that any index on `field1` wouldn't be used due to the function call.
Alternatively (and more index friendly)
select * from table1
where field1 >= to_timestamp('2012-01-01', 'YYYY-MM-DD')
and field1 < to_timestamp('2012-01-02', 'YYYY-MM-DD')
Problem
I have a timestamp field and I just want to compare the date part of it in my query in Oracle How do I do that, ``` SELECT * FROM Table1 WHERE date(field1) = '2012-01-01' ```