Manish Gupta
Manish Gupta

Reputation: 4666

Postgresql Remove $ sign money datatype

I have a column (type numeric). I type cast it to Money in postgresql as

Cast (amount_total as money)

When i query data it shows like

$ 1,026,073.00

How to remove this dollar sign?
And if possible can i replace it with a indian rupee sign?

Upvotes: 3

Views: 4421

Answers (1)

Vao Tsun
Vao Tsun

Reputation: 51529

sure, check if your OS supports it:

bash# locale -a | grep en_IN
    en_IN
    en_IN.utf8

then SQL:

SQL> set LC_N

SQL> set LC_MONETARY='en_IN';
SET
SQL> select 1.2::float8::numeric::money;
 money
--------
 ₹ 1.20
(1 row)

read

and in case you just want to get rid of dollar sign, substr from second symbol (will work for your current en_US locale):

td=# SELECT substr('12.34'::float8::numeric::money::text,2);
 substr
--------
 12.34
(1 row)

Upvotes: 1

Related Questions