# Calculate hours worked minus lunch

B

#### becky250

Im sure this has been asked before but i cant seem to find the right code. I
have fields that are Start Time, Finish Time, Lunch In, Lunch Out and Hours
Worked. I would like to create something that calculates the time worked in
between start time and finish time minus the time between lunch in and lunch
out. This would be known as Hours Worked. So if it was 9-5 with an hour for
lunch total hours worked would be 7. All values are in as time except for the
hours worked which would just be a number. Ive seen codes before that
calculate the time in between but im not sure how to calculate the time taken
for lunch also and take this away from the total.

Any help appreciated.

T

#### tina

assuming that LunchOut is when the employee clocks out for lunch, and
LunchIn is when the employee clocks back in after lunch, and assuming that
all four fields are date/time fields (not Number fields), try

HoursWorked: DateDiff("h",[[StartTime],[LunchOut]) +
DateDiff("h",[LunchIn],[FinishTime)

that will return whole hours. or you can change the interval argument from
"h" hours to "n" minutes, and then divide the total by 60 to get hours.

hth

K

#### Klatuu

=(DateDiff("n", [Start Time], [End Time]) - DateDiff("n", [Lunch In], [Lunch
Out])) /60

K

#### Klatuu

There you go again, Dale. Imposing reality on an otherwise perfect solution.
But, I did forget to get my soapbox out on the store calculation issue.

#### Janettx

I found this post and it works great except for when an employee works from 8:00pm to 8:00 am, which throws a negitive number. the number is correct except for it is showing -12. Is there a way to force the negitive number to a possitive number?
Thanks,
Janet