?
Solved

Calculating total hours worked?

Posted on 2010-08-15
2
Medium Priority
?
497 Views
Last Modified: 2013-11-28
I am trying to calculate the total hours worked per individual but I'm unsure how to do this with a query.

For instance, Table 1 may look like this:

ID         EmployeeID             DTStart                                DTEnd                                 Total Hours?
1          1234                      15/08/2010 11:30:00            15/08/2010 18:45:00
2          5678                      16/08/2010 08:45:00            16/08/2010 18:45:00
3          5678                      16/08/2010 22:10:00            17/08/2010 02:30:00
4          3456                      16/08/2010 22:00:00            16/08/2010 23:30:00
5          5678                      18/08/2010 18:00:00            19/08/2010 01:30:00


If for example I wanted to know the total hours for employee 5678, how could I work this out in an access query?  I need two results, the first, total hours each instance, and the second total hours combined for each employeeID?

Any ideas would be greatly appreciated thanks,

Jon
0
Comment
Question by:JonB1984
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 93

Accepted Solution

by:
Patrick Matthews earned 2000 total points
ID: 33440763
Assuming DTStart and DTEnd are both using date/time data type, in Access:
SELECT EmployeeID, Sum(DTEnd - DTStart) * 24 AS HrsWorked
FROM [Table 1]
GROUP BY EmployeeID

Open in new window

0
 

Author Closing Comment

by:JonB1984
ID: 33440922
This works brilliantly for the first part of my question and I can get the rest sorted myself now.

Thanks,

Jon
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question