0

How to store and deal with Mysql currency money value data?

Since money needs an exact representation don’t use data types that are only approximate like float. You can use a fixed-point numeric data type for that like

numeric(15,2)
15 is the precision (total length of value including decimal places)
2 is the number of digits after decimal point
See MySQL Numeric Types:

These types are used when it is important to preserve exact precision, for example with monetary data.

 

I personally use numeric(19,4) for financial records that gives you a better hand to play and adopt new requests easily.

facebooktwittergoogle plus


Leave a Reply