MySQL Double Field

MySQL doesn’t have a money field. So you end-up using double datatype to store Money values. Make sure you’re removing the ‘$’ character and commas from your money values before storing. Otherwise it would end-up truncating your values.

For example:

if you try to store 2,000.00 in your insert statement. Then it will only store 2 in the field. As it considers comma as a non-integer and discards the remaining digits in the number.

I figured this hard way, when a transaction of $2,000 ended up as only $2.00 in my database. 🙂

Advertisements
This entry was posted in MySQL. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s