0

format

With the function, you can format numbers, date, and time values as you need them, to use them in text or formula fields.

ℹ️ Note: All entries are optional. If you do not specify anything, nothing will be formatted.

Caution: 

When calling format() in a server or transaction context (do as server ... end / do as transaction ... end) to convert date and time values, you must use date() or datetime() to provide format() with a valid value, for example:

do as server format(date(DATE), “YYYY-MM-DD”) end

or

do as server format(datetime(DATETIME), “YYYY-MM-DD - hh:mm:ss”) end

If you want to format numbers with this function, you must specify the defaults for formatting in a certain order:

  1. First, specify whether a prefix should be inserted, e.g. a currency symbol.
  2. Should a 1000 separator be inserted?
  3. Specify whether or how many decimal places you want to display.
  4. Specify a unit, e.g. a currency sign.
  5. Type of decimal place separator. In English-speaking countries, this is typically a period (.), while in many other regions a comma (,) is used. Other possible options include single quote (') or double quotes (").
  6. Type of 1000 separator. In English-speaking countries, this is typically a comma (,), while in regions that use a comma as decimal separator, a period (.) or space is common. Other options include single quotation mark (') or double quotation marks (").

Caution: Use double quotes ("") for quotes within a string.

Expected result Formula
238597 format(238597, "")
238597,00 format(238597, ".00")
2387,970 format(2385.97, "0.000#,#")
$2,385.97 format(2385.97, "$#,.#0,0")
2.385,97 € format(2385.97, "#,##0.00 €#,#0.0")

Syntax

format(number, string)

format(date, string)

format(date, string, string)

format(appointment, string)

format(appointment, string, string)

format(timestamp, string)

format(timestamp, string, string)

format(time, string)

Return

string

Examples

Caution: Your result format may be different depending on your settings.

ℹ️ Note: Examples include both period and comma as decimal separators to accommodate users in different regions. In the English-speaking world, '$2,385.97' format is standard, while in many European countries, '2.385,97 €' would be the expected format.

format(myNumber, formatExpression) to format a given number as a string.

format(2385.97, "#,##0.00 €#,#0.0")

Result: 2.385,97 €

format(2385.97, "$#,.#0,0")

Result: $2,385.97

format(12345, "0000000000")

Result: 0000012345

format(myDate, formatExpression) to format a given date as a string.

format(Date, "ddd, Do MMMM YYYY")

Result:

  • Mon, May 31, 2021 (with Date = 05/31/2021) (US)
  • Mon, 31st May 2021 (with Date = 31/05/2021) (UK)

format(myDate, formatExpression, language) to format a given date as a string, where the result shows in a specific language supported by Ninox.

format(myDatetime, formatExpression) to format a given timestamp as a string.

format(now(),"X")

Result: 1622466387 (on May 31, 2021 15:06)

X shows the result without milliseconds. x shows the result with milliseconds.

format(myAppointment, formatExpression) to format a given start of an appointment as a string.

format(myAppointment, formatExpression, language) to format a given start of an appointment as a string, where the result shows in a specific language supported by Ninox.

format(myTime, formatExpression) to format a given time as a string.

format(myDatetime, formatExpression, language) to format a given timestamp as a string, where the result shows in a specific language supported by Ninox.

ℹ️ More information about our date and time format expression .

Reply

null