THE WORLD'S LARGEST WEB DEVELOPER SITE

MySQL FORMAT() Function

❮ MySQL Functions

Example

Format the number as a format of "#,###.##" (round with two decimal places):

SELECT FORMAT(250500.5634, 2);
Try it Yourself »

Definition and Usage

The FORMAT() function formats a number as a format of "#,###.##", rounding it to a certain number of decimal places. Then it returns the result as a string.

Syntax

FORMAT(number, decimal_places)

Parameter Values

Parameter Description
number Required. The number to format
decimal_places Required. The number of decimal places to round the number

Note

  • If decimal_places is 0, the FORMAT() function returns a string with no decimal places

Technical Details

Works in: MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23

More Examples

Example

Format the number as a format of "#,###.##" (round with no decimal places):

SELECT FORMAT(250500.5634, 0);
Try it Yourself »

❮ MySQL Functions