FORMAT

2026-02-11 07:43:39  Updated

Syntax

FORMAT(X,D)

Purpose

FORMAT() converts the number X into the #,###,###.## format, rounds the value to D decimal places, and returns the result as a string.

If the integer part exceeds three digits, commas (,) are used as thousands separators.

If D is 0, the result has no decimal point or fractional part.

Examples

obclient> SELECT FORMAT(12332.123456, 4) FROM DUAL;
+-------------------------+
| format(12332.123456, 4) |
+-------------------------+
| 12,332.1235             |
+-------------------------+
1 row in set

obclient> SELECT FORMAT(12332.1, 4) FROM DUAL;
+--------------------+
| format(12332.1, 4) |
+--------------------+
| 12,332.1000        |
+--------------------+
1 row in set

obclient> SELECT FORMAT(12332.2, 0) FROM DUAL;
+--------------------+
| format(12332.2, 0) |
+--------------------+
| 12,332             |
+--------------------+
1 row in set

Contact Us