0

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?

Nick Krasnov
  • 26,886
  • 6
  • 61
  • 78
MontyPython
  • 2,906
  • 11
  • 37
  • 58

1 Answers1

5

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')
Tony Andrews
  • 129,880
  • 21
  • 220
  • 259