hey i need a way to get a formated number from my column decimal(23,2) NOT NULL DEFAULT '0.00'
in php i could use this function number_format('1111.00', 2, ',', '.');
it would return 1.111,00
(in Germany we use , to define decimal numbers)
how would i do this in mysql? with string replaces?
SELECT ROUND(-4.535,2); Explanation: The above MySQL statement will round the given number -4.535 up to 2 decimal places.
MySQL FORMAT() Function 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.
MySQL FORMAT function examples As you see in the result, the de_DE locale use dot (.) for grouping thousand and comma (,) for decimal mark.
ROUND() Function in MySQL. The ROUND() function in MySQL is used to round a number to a specified number of decimal places. If no specified number of decimal places is provided for round off, it rounds off the number to the nearest integer.
http://blogs.mysql.com/peterg/2009/04/
In Mysql 6.1 you will be able to do FORMAT(X,D [,locale_name] )
As in
SELECT format(1234567,2,’de_DE’);
For now this ability does not exist, though you MAY be able to set your locale in your database my.ini check it out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With