format_date

Use the format_date function to format a date according to the specified mask and language code.

 format_date ( date; template; language )

This function returns a value of type TEXT.

The function has three parameters:

  1. date, type NUMBER. The date to be formatted.
  2. template, type TEXT. The template specifying how the date should be formatted.
  3. language, type TEXT. Optional. The language used to format textual components in the template.

The template must be composed of a sequence of format types. The format types are case-sensitive.

The following format types are supported:

Format Type Description Example

d

Day of the month

2

dd

Day of the month, padded to 2 positions

02

ddd

Abbreviated day of the week

Mon

dddd

Day of the week

Monday

M

Month

3

MM

Month, padded to two positions

03

MMM

Abbreviated month

Mar

MMMM

Month

March

y

Last two digits of the year, omitting a leading 0

15

yy

Last two digits of the year

15

yyyy

The year

2015

g

Period or era

A.D.

gg

Period or era

A.D.

*SHORT

Windows short date format

02/03/2015

*LONG

Windows long date format

02 March 2015

Examples are based on the date 20150302 and the ENG output language.

Spaces in the template appear in the same location in the output. A template can contain text that is not matching any of the format types. This text is mostly passed unchanged. To ensure that text is passed unchanged you should enclose it in single quotation marks. A single quotation mark as fixed text must be written as a sequence of two single quotation marks in a row.

The format types *SHORT and *LONG cannot be combined with other format types or layout.

The language parameter is optional. If it is omitted or empty, the current output language is used. The following values are support for this parameter:

  • Any of the output language supported by KCM Core (see language_code)
  • Any Language Culture Name installed on the Microsoft Windows Server hosting KCM Core

If the language is not supported or the date is invalid the function returns "????".

Examples

format_date (20150302; "MM'//'dd'//'yyyy") results in "03/02/2015"

format_date (20150302; "dd'-'MM'-'''yy") results in "02-03-'15"

format_date (20150302; "dddd") results in "Monday"

format_date (20150302; "*LONG"; language:="SVE") results in "den 3 februari 2015"

format_date (20150302; "*LONG"; "nl-NL") results in "dinsdag 3 februari 2015"

format_date (20150229; "yyyy") results in "????" (invalid date)

format_date (20150302; "yyyy"; "tlh") results in "????" (invalid language)

The earliest date supported by this function is Jan 1, 1601 (16010101).

The implementation of the format_date function depends on the Microsoft Windows NLS support. The output can depend on the version of Microsoft Windows and installed components. For a detailed description of the supported templates, see the Microsoft Windows documentation on Day, Month, Year, and Era Format Pictures available on the Internet.

The format_date function was introduced in KCM Core 4.4.