Product Documentation

SQL Reference Guide

Previous Topic

Next Topic

Time Format Strings

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.

AM

The string "AM" or "PM" depending on whether time corresponds to forenoon or afternoon.

PM

The string "AM" or "PM" depending on whether time corresponds to forenoon or afternoon.

A.M.

The string "A.M." or "P.M." depending on whether time corresponds to forenoon or afternoon.

P.M.

The string "A.M." or "P.M." depending on whether time corresponds to forenoon or afternoon.

HH12

The hour value as a two-digit number (in the range 00 to 11).

HH24

The hour value as a two-digit number (in the range 00 to 23).

HH

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).

Example

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

TOCIndex