Page 1 of 1

only calculate before the comma

Posted: Tue Jul 01, 2008 12:16 pm
by nitation
Hello people,

I am having problems with the comma sign in the amount field. I have a figure in my amount field that looks like this;

7500004

when i try to transfer a sum that looks like 750,0004, it will only calculate all the figures before the comma.

I wanna know if i have an error in my database or what.

my table looks like this

amount varchar(255);

do i need to change the column type to something like FLOAT, DECIMAL or what.

Thanks in advance

Re: only calculate before the comma

Posted: Tue Jul 01, 2008 1:04 pm
by califdon
nitation wrote:Hello people,

I am having problems with the comma sign in the amount field. I have a figure in my amount field that looks like this;

7500004

when i try to transfer a sum that looks like 750,0004, it will only calculate all the figures before the comma.

I wanna know if i have an error in my database or what.

my table looks like this

amount varchar(255);

do i need to change the column type to something like FLOAT, DECIMAL or what.

Thanks in advance
There's no problem with your database. All databases that I know of store numbers without commas as "thousands" markers. That's totally a U.S. practice, anyway. Since databases are used around the world, the way they store data must be compatible with other languages and practices. There are ways to display large numbers with commas, but they are never stored that way, so you must never input them that way. You can use the preg_replace() function to remove any commas before writing to a record in the database.