I am having query on the below sql.
Please help me.
select to_date(sysdate, 'DD MONTH YYYY') , to_date(sysdate, 'yyyy/mm/dd hh24:mi:ss')
from dual where
to_date(sysdate, 'DD MONTH YYYY') < to_date(sysdate, 'yyyy/mm/dd');
1) to_date(sysdate, 'DD MONTH YYYY') this will give Date object without time (may be time is 00:00).
Am i correct ? If not how will i get only Date object without Time in it?
2) From the above query It seems to_date(sysdate, 'yyyy/mm/dd') is greater than to_date(sysdate, 'DD MONTH YYYY'). Why ??
Update
1) My aim in the above URL is to find out to_date function will only return date (or along with time) though format 'DD MONTH YYYY' is not mentioning the time chars(hh:mm..) in it.
2) From the response i got that to_date will return Date with time always though we didn't mention the time chars.
3) Finally to get only DATE we should use trunc() / to_date(to_char(sysdate,'mm-dd-yyyy'),'mm-dd-yyyy')
Check the below
select to_char(trunc(sysdate), 'yyyy/mm/dd hh24:mi:ss'),
to_char(to_date(to_char(sysdate, 'yyyy-MM-dd'),'yyyy/mm/dd hh24:mi:ss'),'yyyy/mm/dd hh24:mi:ss')
from dual;
-->hh24 :24 is important to get 00:00 format.
sysdate
which is already a date into a date. – a_horse_with_no_name