Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL, Format Float

Tags:

postgresql

I try to format numeric field

select to_char(12315.83453, 'FM999999999999D9999')

in this case all its OK. Result is 12315.8345

But if value is between 0 and 1

select to_char(0.83453, 'FM999999999999D9999')

result is .8345 without 0 (zero) but I need 0.8345.

What kind of format should be indicate to to_char function to obtain result what I need?

like image 875
Dumitru Avatar asked Sep 12 '26 22:09

Dumitru


1 Answers

SELECT to_char(0.83453, 'FM999999999990D9999');

I just changed the 9 before format D to 0.

like image 84
Dan LaRocque Avatar answered Sep 15 '26 14:09

Dan LaRocque



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!