Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 141
  • Last Modified:

Data Type

Hi,
  I was wondering if I stored currency in my database as a Text Field, for instance the data can be 5.00 or $5.00 or simply 5, how do I add $10 to that field?

Nick
0
SolverSurfer
Asked:
SolverSurfer
4 Solutions
 
MauseCommented:
Hi,

Difficult if its only a number it would be easy by just do 5 + 10 but if you also store the $ you must first remove it before you can add something to it. It would sugest not to store the currency value in the same field

Mause
0
 
mrichmonCommented:
You may be able to store it as text and then do a conversion on the data before you do the addition and then convert back to save it - this could all be done int he one DB call.

what kind of database do you have? - I am guessing access in which case there are not as many DB side functions supported

It is probably best to try to store any numeric values that you will need to be manipulating as a numeric type (currency, float, double, etc)
0
 
SolverSurferAuthor Commented:
It is Microsoft Access
0
 
anandkpCommented:
Store it as a number "data type"

& while displaying use "dollarformat()" to get the $

Once u have it as a number data type in Database - adding 10 to it wld be

Update table set currency_column = currency_column + 10
0
 
Tacobell777Commented:
Store it as currency like it should be stored, it is currency so use the datatype currency.
To get the $ sign you could use lsCurrencyFormat() or dollarFormat()
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now