Sunitha Sunitha - 3 years ago 165
SQL Question

date format conversion am to date

I need a help on how to convert

'09-07-15 07:41:01AM'
to
'2015-07-09 07:41:01'.


I have tried below query but it is not giving accurate result.

select to_char(to_date('09-07-15 07:41:01AM'
,'DD-MM-YYYY HH:MI:SS AM')
,'YYYY-MM-DD HH24:MI:SS') from dual

Answer Source

Have you tried

select to_char(add_months(to_date('09-07-15 07:41:01AM','DD-MM-YY HH:MI:SS AM'),24000),'YYYY-MM-DD HH24:MI:SS') from dual

It looks like you have to many Y's, and your M's ans D's are inconsistent!

I'm not sure if it should be YY-MM-DD or YY-mm-dd?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download