Looking to convert time format from 24hour to 12hour in Teradata but heading nowhere.
E.g., I have 22:30:45 and I want 10:30:45PM
Here is a way to covert a 24-hour time format to a 12 hour format with AM/PM
SELECT TO_CHAR(CAST('22:30:45' AS TIME), 'HH12:MI:SSAM') AS converted_time;
CAST('22:30:45' AS TIME)
: Converts the string into a TIME
datatype.
TO_CHAR(..., 'HH12:MI:SSAM')
:
HH12
→ Converts to 12-hour format.
MI
→ Stands for minutes.
SS
→ Stands for seconds.
AM/PM
→ Appends AM or PM based on the time.