waht kind of fields do you use for currencies (money)?
i.e. a good may be sold in different currencies,
i.e. $100.10 US dollars or $60.32 EU dollars,
how do you describe the situation?
I prepare to use:
(field 1) DOUBLE for amount of money (i.e. 100.10)
(field 2) CHAR(20) for type of money (i.e. US)
but I feel this way is not good, please give suggestions.
thanks
need suggestion: fields for money
Moderator: General Moderators
-
php12342005
- Forum Commoner
- Posts: 79
- Joined: Mon Mar 21, 2005 3:35 am
-
php12342005
- Forum Commoner
- Posts: 79
- Joined: Mon Mar 21, 2005 3:35 am
M is digits, B is number of decimal points so
NUMERIC(10) would be an integer with up ten digits + sign.
NUMERIC(10,2) wuld have two decimal place digits and 8 non-decimal place digits.
If you're dealing with prices often NUMERIC(XXX,2) is good where you've chosen an appopriate XXX, then adding 1 or 2 just in case.
If you're dealing more with exchange rates and finanncial matters, you typically need to use 3 decimal places (or more) depending on local laws.
NUMERIC(10) would be an integer with up ten digits + sign.
NUMERIC(10,2) wuld have two decimal place digits and 8 non-decimal place digits.
If you're dealing with prices often NUMERIC(XXX,2) is good where you've chosen an appopriate XXX, then adding 1 or 2 just in case.
If you're dealing more with exchange rates and finanncial matters, you typically need to use 3 decimal places (or more) depending on local laws.
Currency
Perhaps you could store all amount in one currency type (e.g US Dollar)
Then you could use conversions to convert the amount from US Dollars to
the local currency based on the exchange rates...
(which you may need to update or get from an external source.)
Then you could use conversions to convert the amount from US Dollars to
the local currency based on the exchange rates...
(which you may need to update or get from an external source.)