To convert the string into a date:
to_date (the_string, 'yyyy-mm-dd hh:mi:ss')
If you then want that to be formatted as a string in format mm-dd-yyyy hh:mi:ss:
to_char (to_date (the_string, 'yyyy-mm-dd hh:mi:ss'), 'mm-dd-yyyy hh:mi:ss')
Domanda
I have a varchar
column and I want to convert yyyy-mm-dd hh:mi:ss
into mm-dd-yyyy hh:mi:ss
and cast it into a date. How can it be done?
Soluzione
To convert the string into a date:
to_date (the_string, 'yyyy-mm-dd hh:mi:ss')
If you then want that to be formatted as a string in format mm-dd-yyyy hh:mi:ss:
to_char (to_date (the_string, 'yyyy-mm-dd hh:mi:ss'), 'mm-dd-yyyy hh:mi:ss')