Calculate hours worked minus lunch



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.


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]) +

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.



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


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.
Mar 18, 2011
Reaction score
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?

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