bugl
bugl
HomeLearnPatternsSearch
HomeLearnPatternsSearch

Loading lesson path

Learn/SQL/SQL References
SQL•SQL References

MySQL FORMAT() Function

Concept visual

MySQL FORMAT() Function

Pointer walk
two pointers
leftright102132436485116
left=0
right=6
1
3

Start at both ends

Example

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

SELECT FORMAT(250500.5634, 2);

Definition and Usage

The FORMAT() function formats a number to a format like "#,###,###.##", rounded to a specified 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 be formatted decimal_places Required. The number of decimal places for number. If this parameter is 0, this function returns a string with no decimal places

Technical Details

Works in:

From MySQL 4.0

More Examples

Example

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

SELECT FORMAT(250500.5634, 0);

Previous

❮ MySQL Functions

Next

Previous

MySQL FIND_IN_SET() Function

Next

MySQL INSERT() Function