I am using Oracle XE on my machine.
Defined a table as :
Name Type
ENAME VARCHAR2(20)
DOJ DATE
Firing a simple select:
select * from test1.tasty1;
ENAME DOJ
sat 08-DEC-16
So ok - I am aware that DATE field has time component in it.
The following query using TRUNC works fine:
select * from test1.tasty1 where trunc(DOJ) = '08-DEC-16';
Now I wanted to test the 'to_date' function - but none of the below queries worked - wonder why ?
select * from test1.tasty1 where DOJ = to_date('08-12-2016','DD-MM-YYYY');
select * from test1.tasty1 where DOJ = to_date('08-DEC-2016','DD-MON-YYYY');
select * from test1.tasty1 where DOJ = to_date('08-DEC-16','DD-MON-YY');
select * from test1.tasty1 where DOJ = to_date('08-DEC-16','dd-mon-RR');
Had taken a look at the following on SO:
Oracle TO_DATE not working
so not sure what is wrong here ?
SELECT * FROM test1.tasty1 WHERE DOJ = '2016-08-12'
... does this return anything? AFAIK some of the 4 queries you tried should be returning that record. – Tim BiegeleisenWHERE DOJ = '2016-08-12'
– Tim BiegeleisenDOJ
is adate
column? This is very strange behavior I am seeing here. – Tim Biegeleisen