ikmyer Posted January 27, 2007 Share Posted January 27, 2007 Looking for suggestions on the best way ( what data type ) to store $ amounts in mysql...ex.$10.00$99.99$1000.05(storing without the $ of course )Thanks,ikmyer Quote Link to comment https://forums.phpfreaks.com/topic/35985-solved-storing-money-values/ Share on other sites More sharing options...
bibby Posted January 28, 2007 Share Posted January 28, 2007 your field type should prbably be [b]float[/b] Quote Link to comment https://forums.phpfreaks.com/topic/35985-solved-storing-money-values/#findComment-170825 Share on other sites More sharing options...
tippy_102 Posted January 28, 2007 Share Posted January 28, 2007 I think Decimal is more accurate because it stores numbers to a specific number of decimal places. Float and Double give rounded numbers.Add up a bunch of numbers that are stored as Float and Double and they may be out a penny. Add up a bunch of numbers stored as decimal and they will be exact. Accounts and auditors like exact if that may be an issue for you. ;)[url=http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html]http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html[/url] Quote Link to comment https://forums.phpfreaks.com/topic/35985-solved-storing-money-values/#findComment-170950 Share on other sites More sharing options...
artacus Posted January 28, 2007 Share Posted January 28, 2007 Yep, you definitely should use decimal here, (as opposed to float). Quote Link to comment https://forums.phpfreaks.com/topic/35985-solved-storing-money-values/#findComment-171030 Share on other sites More sharing options...
ikmyer Posted January 28, 2007 Author Share Posted January 28, 2007 thanks, I read up on the decimal and I think i will use it. Being exact is an issue. Quote Link to comment https://forums.phpfreaks.com/topic/35985-solved-storing-money-values/#findComment-171160 Share on other sites More sharing options...
bibby Posted January 28, 2007 Share Posted January 28, 2007 heh, I didn't even know about decimal. I guess I gave away that my projects aren't carts.Thanks guys. Quote Link to comment https://forums.phpfreaks.com/topic/35985-solved-storing-money-values/#findComment-171194 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.