'Oracle date comparison using to_date not working

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 ?



Solution 1:[1]

Have you tried like this as comparison of date with date is correct:

select * from test1.tasty1 where to_date(DOJ,'DD-MM-YYYY') = to_date('08-12-2016','DD-MM-YYYY');

Compare apples with apples and not with mangoes.

Solution 2:[2]

What it worked from is instead of make a date to compare, change the date column to char with to_char(datecol, 'DD-MM-YYYY') = '01-01-2022'

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Gaurav Gupta
Solution 2 dippas