Format input into a string


string format(number|string|datetime $data, string $format, string $culture)

Formats $data into a string following the rules defined by $format and $culture. For example, set number of decimals in numbers, or format currency and dates according to locale.


number | string | datetime $data

Data to be formatted. string arguments are accepted, but the formatting is only applied to strings formatted as dates; number formatting cannot be applied to strings, even if they are formatted correctly as numbers.

string $format

To format numbers, use one of the standard numeric format strings, as implemented in .NET.

To format dates, use custom date and time format strings to specify the format.

string $culture

To match the format to a region, use a compound of the language and region IANA tag, e.g., en-US.



Data formatted according to the $format and $culture specifiers.


    a: format(`0.555`, 'f', 'en-US'),
    b: format(`0.555`, 'F2', 'en-US'),
    c: format(to_datetime('02-19-2021', 'MM-dd-yyyy', 'en-US'), 'g', 'en-US'),
    d: format(to_datetime('02-19-2021', 'MM-dd-yyyy', 'en-US'), 'yyyy-MM-dd', 'en-US'),
    e: format(to_datetime('3. maj, 2021', 'd. MMM, yyyy', 'da-DK'), 'd. MMM, yyyy', 'en-US'),
    f: format([`0`], 'd', 'en-US'),
    g: format(`null`, 'd', 'en-US'),
    h: format(`1999`, 'c', 'da-DK'),
    i: format(`1999`, 'N2', 'en-US')
  "a": "0.555",
  "b": "0.56",
  "c": "2/19/2021 12:00 AM",
  "d": "2021-02-19",
  "e": "3. May, 2021",
  "g": "",
  "h": "1.999,00 kr.",
  "i": "1,999.00"