Jump to content


Photo

Math Datatypes for Currency


  • Please log in to reply
2 replies to this topic

#1 nfr

nfr
  • Members
  • PipPipPip
  • Advanced Member
  • 34 posts

Posted 27 February 2006 - 12:28 PM


Hello -

I am trying to build a small accounting system using php/mySQL. What datatypes should I use to store amounts, i.e. monetary values? Also, how can I format the amounts so that they are presented as €xx.yy and not €xx.y if the y value is 40 cents for example?

Regards,

Neil.

#2 litebearer

litebearer
  • Members
  • PipPipPip
  • Advanced Member
  • 2,357 posts
  • Locationwhite lake michigan

Posted 27 February 2006 - 12:55 PM

This might help as regards formatting

[a href=\"http://us2.php.net/money_format\" target=\"_blank\"]http://us2.php.net/money_format[/a]

and here for data types

[a href=\"http://www.htmlite.com/mysql003.php\" target=\"_blank\"]http://www.htmlite.com/mysql003.php[/a]

Hope it helps.

Lite...

all the brothers were valiant!

[br][br]The truely intelligent people are not those who create the dots; rather they are they ones with the ability to connect the dots into a coherent picture

#3 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 27 February 2006 - 01:10 PM

as for datatypes in the DB, FLOAT(6,2) usually works quite well for me, but i don't typically use anything with HUGE numbers, so you may want to increase that a bit for your needs.
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users