Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to format money in PostgreSQL

Tags:

postgresql

I have float field that contains (for example): 1234.5678. I would like to display it like a 1 234.56 or 1 234,56. How can I do that?

I used to_char() function that gives me:

SELECT to_char(12345.5678,'99999999999999999D99');
-> 12345,57

but, when I have zero-value...

SELECT to_char(0,'99999999999999999D99');
-> ,00
like image 974
Bald Avatar asked Nov 15 '25 12:11

Bald


1 Answers

A zero inside:

SELECT to_char(0,'99999999999999990D99');
-- Second question from the comments: Howto make k-seperator
SELECT to_char (1234567890999999.8,'99 999 999 999 999 990D99');

Here is the online-doku: functions (data-type conversion). Maybe you like to download it.

like image 166
user unknown Avatar answered Nov 18 '25 20:11

user unknown



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!