Spark13
Spark13

Reputation: 146

How to set precision in money data type (PostgreSQL)?

I want to have 4 fraction digits in money datatype column (DB PostgreSQL 10, Windows). Please advice me how to do that? Documentation says: The fractional precision is determined by the database's lc_monetary setting. But what exact value I should set up? For example, I want to store $0.4358 instead of $0.44.

Upvotes: 2

Views: 2187

Answers (1)

Vao Tsun
Vao Tsun

Reputation: 51456

I'm afraid you can't do that with money datatype. The control over the fraction with lc_monetary would be such:

t=# set lc_monetary TO 'ar_KW.UTF-8';
SET
t=# SELECT '52093.892'::money;
      money
-----------------
 د.ك. 52,093.892
(1 row)

so if locale actually means to have more digits, you will have them. See https://en.wikipedia.org/wiki/ISO_4217#Active_codes

Upvotes: 1

Related Questions