Gossamer Forum
Home : General : Databases and SQL :

Monetary Columns

Quote Reply
Monetary Columns
Here I go with another question...

What is the safest column to use when dealing with monetary units, the precision required is only within 1 cent.

Do I use an INT and deal in cents, or use a FLOAT (I understand you can get weird things happen when doing multiple calcualtions... rounding etc), or something else?

I noticed this: salary DECIMAL(5,2) in:http://www.mysql.com/doc/N/u/Numeric_types.html , but I am not exactly sure about its use, or if it also has problems like the FLOAT.

Crazy


http://www.iuni.com/...tware/web/index.html
Links Plugins
Quote Reply
Re: [Ian] Monetary Columns In reply to
I think they recommend DECIMAL(12,2).. Ah, found it:

http://www.mysql.com/...tax_differences.html

That's what they use in replacement of Msql's built in MONEY type.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Monetary Columns In reply to
For money then:

{ type => 'DECIMAL(12,2)' , default => 0.00, regex => '^\d+\.?\d*$' }

Thanks,

Ian


http://www.iuni.com/...tware/web/index.html
Links Plugins
Quote Reply
Re: [Ian] Monetary Columns In reply to
Nope:

{ type => 'DECIMAL', precision => 12, decimal => 2, default => 0, regex => '^\d+\.?\d*' }

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Monetary Columns In reply to
Ahhh,

Thanks again!


http://www.iuni.com/...tware/web/index.html
Links Plugins