Thread: Monetary, Float Types

Monetary, Float Types

From
Rob Cleveland
Date:
I am trying to add prices together using either the monetary type or float4 type.  Monetary doesn't seem to add, and float4 renders results out to 7 decimal places. Also, float4 doesn't display prices with .00 cents.  Which data type should I use to solve this problem?
 
 

Re: [GENERAL] Monetary, Float Types

From
darcy@druid.net (D'Arcy J.M. Cain)
Date:
Thus spake Rob Cleveland
> I am trying to add prices together using either the monetary type or =
> float4 type.  Monetary doesn't seem to add, and float4 renders results =

darcy=> select '12.34'::money + '43.21'::money;
?column?
--------
$55.55
(1 row)

Can  you show an example that doesn't work?

--
D'Arcy J.M. Cain <darcy@{druid|vex}.net>   |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 424 2871     (DoD#0082)    (eNTP)   |  what's for dinner.