Calculate Number of Employees Who Were At Work Each Hour?

Hiroyuki Tamura
Hiroyuki Tamura used Ask the Experts™
on
Calculate Number of Employees Who Were At Work Each Hour on MS Access?

I am trying to come up with a set of formulas to calculate how many employees were on the clock fo each hour of the day based on:

https://www.mrexcel.com/forum/excel-questions/614617-calculate-number-employees-who-were-work-each-hour.html

The link provide the solution for MS Excel but I would like to build with MS Access.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Hamed NasrRetired IT Professional

Commented:
Upload a sample table with few representative records.
Show the required output.
Distinguished Expert 2017
Commented:
To do this you would need to create a new table with 24 rows.  One for each hour.  Then you would need to make a query that joins to this table using a non-equi join.

I don't even want to think about how to do this if your start-end spans midnight so I'm going to assume it doesn't for now.

Select tblA.StartDateNoTime, tblHours.Hour, 1 as Present
Inner Join tblA to tblHours On tblHours.Hour Between tblA.Starthour and tblA.EndHour

To get starthour and end hour you would need to extract them from start time and end time.  You can do this easily enough by creating a query that extracts and formats tblA as needed.

This query generates 1 row per person per hour present.  The final query sums the results of this one.

Before going any further, we will need to know if start date and end date spans midnight.  The easiest solution for that might be to split the record into two.  Start - 11:59 and 12:00- End.   If the end is 12:00, don't create the second record.
Hiroyuki TamuraField Engineer

Author

Commented:
Thank you!
I'll try and let you now.
Hiroyuki TamuraField Engineer

Author

Commented:
Works great!
Distinguished Expert 2017

Commented:
Glad you were able to understand the directions.  This isn't a trivial task.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial