Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Working with decimal numbers MySQl & ASP

Status
Not open for further replies.

SmokeyJoe

Programmer
Nov 13, 2000
80
US
I recently became treasurer of a club and decided to write a small program using localhost to keep track of the income and expenses. I am having problems changing the bank balance when I write or deposit a check.

It appears that with MYSQL data types for numbers are limited to Intgers and strings (Decimal is a string according to my book). Using varchar to hold my bank balance the following works.
The following works when writing a check
vBankBal = vBankBal - vCkAmt

Using the reverse to deposit a check concatenates the two strings:
vBankBal = vBankBal + vCkAmt
I know I am being stupid but what type field would I use or how would i add the two fields to give the new bank balance

Thanks in advance
 
You would not use a CHAR or VARCHAR to hold numeric data like a bank balance. DECIMAL is fine, and so is INTEGER of various sizes. FLOAT/DOUBLE is also available, but not suitable here because it gives rounding errors. My own preference is for INTEGER/BIGINT because it's faster, but the amounts must be stored in cents, then divided by 100 before being displayed.
 
Thanks Tony, That is about what I had concluded.

Smokey Joe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top