How to: |
There are two versions of the CHAR function, one for converting an argument to a character string, and one for converting a date, time, or timestamp value to a standard format. The version that takes two arguments converts a date, time, or timestamp value to one of the standard date-time formats. For information about using CHAR to convert a single argment to a character string, see CHAR: Converting to a Character String.
CHAR(datetime, fmt)
where:
Date
Is the date, time, or timestamp value to be converted.
Can be one of the following formats:
Name of Standard | Date Format | Time Format | Timestamp Format |
---|---|---|---|
ISO | yyyy--mm--dd | hh.mm.ss | yyy--mm--dd hh:mm:ss.xxxxxx |
USA | mm/dd/yyyy | hh.mm AM/PM | yyyy--mm--dd--hh.mm.ss.xxxxxx |
EUR | dd.mm.yyyy | hh.mm.ss | yyyy--mm--dd--hh.mm.ss.xxxxxx |
JIS | yyyy--mm--dd | hh:mm:ss | yyy--mm--dd--hh.mm.ss.xxxxxx |
This function returns a character string whose length is of sufficient size to hold the value.
CHAR converts a date, time, or timestamp value to a standard format. The following examples use the constants CURRENT DATE, CURRENT TIME, and CURRENT TIMESTAMP. Assume the current date is November 17, 2011:
CHAR(CURRENT DATE, USA) returns 11/17/2011
CHAR(CURRENT DATE, ISO) returns 2011-11-17
CHAR (CURRENT TIME, USA) returns 03:45 PM
CHAR (CURRENT TIME, ISO) returns 15.45.00
CHAR(CURRENT TIMESTAMP, ISO) returns 2011-11-17 15:45:00
iWay Software |