Solved

Calculating total hours worked?

Posted on 2010-08-15
2
482 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
2 Comments
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

825 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