Useful shortcuts for vi editor

Thursday 18 December 2014

How to use to_date function?

e.g.
select to_date('2014-12-18','yyyy-mm-dd') from dual;
output: 12/18/2014

select to_date('2014-12-18 12:15','yyyy-mm-dd hh:mi') from dual;
output: 12/18/2014 12:15:00 PM

select to_date('2014-12-18 13:15:55','yyyy-mm-dd hh24:mi:ss') from dual;
output: 12/18/2014 1:15:55 PM

select to_date('2014-12-18','yyyy-mm-dd') - 7 from dual;
output: 12/11/2014

select to_char(to_date('2014-12-18','yyyy-mm-dd') + 30,'DAY') from dual;
output: SATURDAY

select to_char(to_date('2014-12-18','yyyy-mm-dd') + 365,'MONTH') from dual;
output: DECEMBER