Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
Solved

# Calculating total hours worked?

Posted on 2010-08-15
Medium Priority
500 Views
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
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

LVL 93

Accepted Solution

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
``````
0

Author Closing Comment

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

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
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…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
###### Suggested Courses
Course of the Month8 days, 22 hours left to enroll