Product Documentation

SQL Reference Guide

Previous Topic

Next Topic

Date-Time Format Strings

The TO_CHAR scalar function supports a variety of format strings to control the output of date and time values. The format strings consist of keywords that FairCom DB SQL interprets and replaces with formatted values.

The format strings are case sensitive. For instance, FairCom DB SQL replaces ‘DAY’ with all uppercase letters, but follows the case of ‘Day’.

Supply the format strings, enclosed in single quotation marks, as the second argument to the TO_CHAR function.

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

For details of the TO_CHAR function, see "TO_CHAR".

In This Section

Date Format Strings

Time Format Strings

TOCIndex