Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Query to calculate hours worked per day.

$
0
0
Hi all, I'm hoping someone can help me out with this, or at least point me to a specific post where this has already been covered. I'm sure this is probably very simple, and I'm just overthinking it.

I've been tasked with building a payroll database in Access 2007 for our per diem staff. They can work on multiple cases in one day, and some of those cases do carry over into the next day. Also, multiple staff members can work on the same case, so there would be multiple entries for the same case, which links to the main Case table in a (many-to-one relationship). The table for their hours is called Time Card Hours, and is set up as follows:
CaseID - text
StaffCode - text
DateIn - short date
TimeIn - long time
DateOut - short date
TimeOut- long time

Example: Tech1 starts a case at 8:30 PM on 10-20-2012 and finishes at 3:00 AM on 10-21-2012. Tech1 then starts another case at 10:45 AM and finishes at 4:00 PM. Tech1 then logs time from 6:00 PM to 7:30 PM on paperwork, before getting one last case, starting at 11:10 PM, and ending at 4:35 AM on 10-22-2012.

I've been able to successfully calculate the total time spent on each case, even spanning midnight, with DateDiff, but I haven't been able to figure out how to calculate the total time spent working each day by the tech. This is extremely important because California law dictates that overtime be applied if more than 8 hours are worked in any given day. Would I be better off doing these calculations in a report instead of a query? Is this possible with the way I have my table currently structured? I did add fields for the start and end date of each day (12:00:00 AM and 11:59:59 PM), but don't know if it's of any help. I'm really in a bind here, can anyone help me out please?

Viewing all articles
Browse latest Browse all 13329

Trending Articles