For a project, I created a table with a column price MONEY NOT NULL
column. And I thought it would handle decimals properly, unlike a floating number (i.e. IEEE rounding issues), but I end up having values like $9.94
(string) being returned from the database, instead of 9.94
(numeric). Having to manually manipulate the field value by removing the dollar sign is silly; is there a way to have a MONEY
column without a currency sign?
If not, what's the best data type replacement to handle currency values?
MONEY
datatype in Postgres is for dollars only. ;) – ypercubeᵀᴹ Jan 15 '15 at 18:55LC_MONETARY
db variable. – Yanick Rochon Jan 15 '15 at 19:02money
a rather useless datatype.numeric
is much better and more flexible. – a_horse_with_no_name Jan 15 '15 at 19:54MONEY
is a great datatype, in theory. It's stored as a 64bit binary integer with an implied, fixed number of decimals. This means that storage is conserved and operations are always as fast and exact as possible (to the specified decimal precision.) It's a pity you can't specify the precision on a column-by-column basis (such asMONEY(2)
andMONEY(4)
) and that by default it prints numbers in a silly way:$1,200.00
– Tobia Nov 30 '16 at 10:29