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?
Asked
Active
Viewed 4,962 times
0

Nick Krasnov
- 26,886
- 6
- 61
- 78

MontyPython
- 2,906
- 11
- 37
- 58
1 Answers
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
-
3+1 and if date in 24-hour format `hh` must be replaced with `hh24` – ThinkJet Aug 10 '13 at 16:04