Rahul
Rahul

Reputation: 13

I want to convert the string 20/01/2017 10:46:19 AM to 2017-01-20 10:46:19 AM in Oracle.

I want to convert a string, like

20/01/2017 10:46:19 AM 

to

2017-01-20 10:46:19 AM 

in Oracle. Any idea guys? I tried using to_date and to_timestamp but it didn't work!

Upvotes: 0

Views: 46

Answers (1)

JohnHC
JohnHC

Reputation: 11195

Convert to date to_date() then to char to_char()

to_char(to date('20/01/2017 10:46:19 AM',
                'DD/MM/YYYY HH:MI:SS AM'), 
        'YYYY-MM-DD HH:MI:SS AM')

Of course, the bigger concern is why you want to store a date as a string...

Upvotes: 5

Related Questions