calculations

R

Ruth

Hi there

How do I get Access to calculate an rate ...
tonnage/(date and time finished-date and time started)

in either the data table or form?
 
A

Al Campagna

Ruth,
Use the DateDiff function to find the difference between StartDT and
StopDT.
You don't indicate how you want the difference... in hours, days,
minutes, etc...
DateDiff("h", StopDT, StartDT)
would yield hours between the two times.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
J

John W. Vinson

Hi there

How do I get Access to calculate an rate ...
tonnage/(date and time finished-date and time started)

in either the data table or form?

Well, you can't and shouldn't in the data table. A Table is NOT a spreadsheet
and does not support calculations, nor should you store calculated values!

You can do calculations in a couple of ways. In a Query you can use a
calculated field by typing an expression in a vacant Field cell, such as

Rate: [tonnage] / DateDiff("h", [time started], [time finished])

to divide the tonnage by the number of hours between the times (use "n" for
miNutes, "m" for Months, "d" for Days etc.)

Or you can use a similar expression preceded by an = sign rather than a new
fieldname in the Control Source of a form or report textbox.

John W. Vinson [MVP]
 
Top