A time format string can contain any of the following format keywords along with other characters. The format keywords in the format string are replaced by corresponding values to get the result. The other characters are displayed as literals.

The following table lists the time formats and their corresponding descriptions.

Table 1. Time formats and descriptions
Time format Description
AM PM The string AM or PM depending on whether time corresponds to morning or afternoon
A.M. P.M. The string A.M. or P.M. depending on whether time corresponds to morning or afternoon
HH12 The hour value as a two‑digit number (in the range 00 to 11)
HH HH24 The hour value as a two‑digit number (in the range 00 to 23)
MI The minute value as a two‑digit number (in the range 00 to 59)
SS The seconds value as a two‑digit number (in the range 00 to 59)
SSSSS The seconds from midnight as a five‑digit number (in the range 00000 to 86399)
MLS The milliseconds value as a three‑digit number (in the range 000 to 999)

Example

The following example illustrates the TO_CHAR function, and the Day, Month, dd, and HH12 format strings:

SELECT C1 FROM T2;
 C1
--
09/29/1952
 1 record selected
  SELECT TO_CHAR (C1, 'Day, Month ddth'),
   TO_CHAR (C2, 'HH12 a.m.') FROM T2;
 TO_CHAR (C1,DAY, MONTH DDTH) TO_CHAR (C2,HH12 A.M.)
---------------------------- ----------------------
Monday , September 29th 02 p.m.
1 record selected