Originally Posted by
BobW2961
Our 1st shift is 7:00am to 3:00pm
I.e. shifts are starting at 7.00 AM, 3:00 PM, and 11:00 PM. So at start you have to decide, to which date 3rd shift time recordings belong. There are 3 possibilities:
1. They belong all to date when shift started (i.e. 1 hour from today 11:00 PM to midnight and 7 hours from midnight to 7:00 AM tomorrow are todays working hours);
2. They belong to date with most working hours (i.e. 1 hour from today 11:00 PM to midnight and 7 hours from midnight to 7:00 AM tomorrow working hours from tomorrow);
3. They belong to their real date (i.e. todays working hours are starting from past midnight and end with next midnight - 3rd shifts are splitted between 2 dates.
Only after you decided about 3rd shift, you can start to design the query for report. I think you have an UNION query where original your original data is splitted between quite a number of several subqueries, like
Code:
(Select auto data from 1st and 2nd shift with original date in result where start time was before end of shift and end time was after start of shift)
UNION
(Select manual data from 1st and 2nd shift with original date in result where start time was before end of shift and end time was after start of shift)
UNION
(Select auto data from 3rd shift with original date in result where start time was before end of previous 3rd shift and end time was after past midnight) //in case you decided for option 3.
Or
...