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?

有帮助吗?

解决方案

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')
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top