webCOMAND

FORMAT()

Formats the number X to a format like '#,##,##.#', rounded to D decimal places, and returns the result as a string. If D is 0, the result has no decimal point or fractional part. If X or D is NULL, the function returns NULL.

The optional third parameter enables a locale to be specified to be used for the result number's decimal point, thousands separator, and grouping between separators. Permissible locale values are the same as the legal values for the lc_time_names system variable.  If the locale is NULL or not specified, the default locale is 'en_US'.

Prototype

string FORMAT(int num, int decimals, string local)

Parameter

  • num - Number to format.
  • decimals - Optional number of decimal places to include.
  • local - Optional local to determine what characters to use for thousands and decimal separators.  For example, 'en_US' or 'de_DE'.

Return

Return a number formatted with commas and to specified number of decimal places.

Example

SELECT OID, Date, FORMAT(Total,2) AS Total FROM Invoice

Related

ROUND()