Convert time to number

  • Thread starter Thread starter houstonthai
  • Start date Start date
H

houstonthai

I have 2 Fields [TimeIn],[TimeOut]. I used the [TimeOut]-[TimeIn] the answer
come out Ok. [18:25].Now I want to Multiply [18:25]*[$23.15] answer is Err.
Please advice me how to do it, I am new in the Access.
 
Use the Datediff command in your query criteria. Datediff("d",[time in],[time
out])
The "d" will give you the answer in days,. If you want it in minutes, I
think it is either m or mm.
 
I have 2 Fields [TimeIn],[TimeOut]. I used the [TimeOut]-[TimeIn] the answer
come out Ok. [18:25].Now I want to Multiply [18:25]*[$23.15] answer is Err.
Please advice me how to do it, I am new in the Access.

Is that $23.15 per hour, or per minute?

In either case, an Access Date/Time value is a number - a count of days and
fractions of a day since midnight, December 30, 1899. It's really not suitable
for durations. I'd use the DateDiff function to calculate the number of
minutes as an integer:

DateDiff("n", [TimeIn], [TimeOut]) * 23.15

Divide by 60 if that number is per hour. Your expression had the $23.15 in
square brackets so Access would assume that it is a (rather strange) fieldname
- DON'T use brackets to surround values; they are used for the *names* of
fields, tables, forms etc. but not for numeric values.
 
You need to use the name of the result. It would look like this.

TotalTime:[TimeOut]-[TimeIn]
TotalAmount:[TotalTime]*23.15
 
Use the Datediff command in your query criteria. Datediff("d",[time in],[time
out])
The "d" will give you the answer in days,. If you want it in minutes, I
think it is either m or mm.

Actually "m" is Months; "n" is miNutes.
 
Back
Top