USING

The USING operator converts date and numeric values to a string based on a formatting mask.

Syntax

expr USING format
  1. expr is a language expression.
  2. format is a string expression that defines the formatting mask to be used.

Usage

The USING operator applies a formatting string to the left operand.

The left operand must be a valid date, integer or decimal number.

The format string can be any valid string expression using formatting characters as described in Formatting numeric values and Formatting DATE values.

Note: DATETIME and INTERVAL expressions cannot be formatted with the USING operator. Use the base.Datetime and base.Interval methods instead. For more details, see Formatting DATETIME values and Formatting INTERVAL values.

The USING operator has a low order of precedence: if you use operators with a higher precedence, the resulting string might not be what you are expecting.

For example, the || concatenation operator is evaluated before USING. As a result:
LET x = a || b USING "format"

will first concatenate a and b, then apply the USING format.

To solve this issue, use parentheses around the USING expression:
LET x = a || (b USING "format")

Example

MAIN
  DEFINE d DECIMAL(12,2)
  LET d = -12345678.91
  DISPLAY d USING "$-##,###,##&.&&"
  DISPLAY TODAY USING "yyyy-mm-dd"
END MAIN