Adding to a Value

K

kikeman

Hi,

I have a column "Hrs" that is a type double in a table "Orders"

I would like to update the value of "Hrs" adding more hours.

"Order" "Hrs"
A3F4TR 5.5

I have to add 2.5 hrs to that order:

"Order" "Hrs"
A3F4TR 8.0

What dould be the UPDATE command for this scenario?

Thanks,
Enrique.
 
D

Dirk Goldgar

kikeman said:
Hi,

I have a column "Hrs" that is a type double in a table "Orders"

I would like to update the value of "Hrs" adding more hours.

"Order" "Hrs"
A3F4TR 5.5

I have to add 2.5 hrs to that order:

"Order" "Hrs"
A3F4TR 8.0

What dould be the UPDATE command for this scenario?


The SQL for an update would be:

UPDATE Orders SET Hrs = Hrs + 2.5
WHERE Orders.Order = 'A3F4TR'

If you wanted to do this for all records in the table, you would just leave
off the WHERE clause.
 
J

Jeff Boyce

Use of the Double data type allows for VERY large numbers ("billions and
billions"), with EXTREME precision (?14 decimal places). I am somewhat
puzzled by your use of this data type for something I believe to represent
hours.

Are you expecting to have billions of hours, or to be able to measure hours
to 14 decimal places?

If not, consider using a different data type ... "Currency" comes to mind
(and no, it isn't only for currency -- it offers no more than four decimal
places and is more accurate for doing math. "Double" uses binary
representation, so there will be binary 'rounding' errors.)

Good luck!

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top