Calculate Number of Employees Who Were At Work Each Hour?

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:

The link provide the solution for MS Excel but I would like to build with MS Access.
Hiroyuki TamuraField EngineerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hamed NasrRetired IT ProfessionalCommented:
Upload a sample table with few representative records.
Show the required output.
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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Hiroyuki TamuraField EngineerAuthor Commented:
Thank you!
I'll try and let you now.
Hiroyuki TamuraField EngineerAuthor Commented:
Works great!
Glad you were able to understand the directions.  This isn't a trivial task.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.