How to calculate working hours per Calendar date

Vommy

New Member
Joined
Mar 6, 2022
Messages
2
Office Version
  1. 2021
Platform
  1. Windows
Hello All,

I would appreciate your help to calculate working hours per calendar date/week/month in 24/7/365 operation. Example: Week starts on Monday at 00.00 and ends on Sunday at 23.59.59. I am struggling to find the solution for past midnight shifts (MOD function does not help).

My data:

HoursPerDate.xlsx
ABC
1EMPLOYEESTART TIMEEND TIME
2ACK02/02/2022 22:0003/02/2022 10:00
3ACK04/02/2022 22:0005/02/2022 06:00
4ACK14/02/2022 06:3014/02/2022 18:30
5ACK15/02/2022 06:3015/02/2022 18:30
6ACK16/02/2022 06:3016/02/2022 16:30
7ATA02/02/2022 22:0003/02/2022 10:00
8ATA04/02/2022 22:0005/02/2022 06:00
9ATA14/02/2022 06:3014/02/2022 18:30
10ATA15/02/2022 06:3015/02/2022 18:30
11ATA16/02/2022 06:3016/02/2022 18:30
12AUB02/02/2022 22:0003/02/2022 10:00
13AUB04/02/2022 22:0005/02/2022 06:00
14AUB14/02/2022 06:3014/02/2022 18:30
15AUB15/02/2022 06:3015/02/2022 18:30
16AUB16/02/2022 06:3016/02/2022 18:30
17BOZ02/02/2022 22:0003/02/2022 10:00
18BOZ04/02/2022 22:0005/02/2022 06:00
19BOZ15/02/2022 07:0015/02/2022 14:00
20BOZ16/02/2022 07:0016/02/2022 15:00
21BOZ19/02/2022 06:3019/02/2022 18:00
22BRA02/02/2022 22:0003/02/2022 10:00
23BRA04/02/2022 07:3004/02/2022 15:30
24BRA14/02/2022 09:0014/02/2022 21:00
25BRA15/02/2022 14:3015/02/2022 23:30
26BRA16/02/2022 14:3016/02/2022 23:30
27BRK02/02/2022 22:0003/02/2022 10:00
28BRK04/02/2022 22:0005/02/2022 06:00
29BRK14/02/2022 14:3014/02/2022 23:30
30BRK15/02/2022 14:3015/02/2022 23:30
31BRK16/02/2022 14:3016/02/2022 23:30
32BRK18/02/2022 18:3019/02/2022 06:30
33BRK19/02/2022 18:3020/02/2022 02:30
34BUČ13/02/2022 14:3013/02/2022 22:30
35BUČ14/02/2022 14:3014/02/2022 23:30
36BUČ15/02/2022 14:3015/02/2022 23:30
37BUL02/02/2022 14:0002/02/2022 22:00
38BUL04/02/2022 14:0004/02/2022 22:00
39BUL14/02/2022 06:3014/02/2022 18:30
40BUL15/02/2022 06:3015/02/2022 18:30
41BUL16/02/2022 06:3016/02/2022 18:30
42DIZ02/02/2022 22:0003/02/2022 10:00
43DIZ04/02/2022 22:0005/02/2022 06:00
44DIZ14/02/2022 06:3014/02/2022 18:30
45DIZ15/02/2022 06:3015/02/2022 18:30
46DIZ16/02/2022 06:3016/02/2022 16:30
47EDI02/02/2022 22:0003/02/2022 10:00
48EDI04/02/2022 22:0005/02/2022 06:00
49EDI13/02/2022 02:3013/02/2022 11:00
50EDI14/02/2022 06:3014/02/2022 18:30
51EDI15/02/2022 06:3015/02/2022 18:30
52EDI16/02/2022 06:3016/02/2022 16:30
53FAT02/02/2022 22:0003/02/2022 10:00
54FAT04/02/2022 22:0005/02/2022 06:00
55FAT14/02/2022 06:3014/02/2022 18:30
56FAT15/02/2022 06:3015/02/2022 18:30
57FAT16/02/2022 06:3016/02/2022 18:30
58GEO02/02/2022 22:0003/02/2022 10:00
59GEO04/02/2022 22:0005/02/2022 06:00
60GEO14/02/2022 06:3014/02/2022 18:30
61GEO15/02/2022 06:3015/02/2022 18:30
62GEO16/02/2022 06:3016/02/2022 18:30
63GLA02/02/2022 22:0003/02/2022 10:00
64GLA14/02/2022 06:3014/02/2022 18:30
65GLA15/02/2022 06:3015/02/2022 18:30
66GLA16/02/2022 06:3016/02/2022 18:30
67GOL14/02/2022 09:0014/02/2022 21:00
68GOL15/02/2022 14:3015/02/2022 23:30
69GOL16/02/2022 14:3016/02/2022 23:30
70GOL18/02/2022 18:3019/02/2022 06:30
71GOL19/02/2022 18:3019/02/2022 23:30
72HRE04/02/2022 22:0005/02/2022 06:00
73HRE19/02/2022 18:3020/02/2022 02:30
74IKI02/02/2022 14:0002/02/2022 22:00
75IKI04/02/2022 14:0004/02/2022 22:00
76IVA02/02/2022 22:0003/02/2022 10:00
77IVA04/02/2022 22:0005/02/2022 06:00
78IVA04/02/2022 22:0005/02/2022 06:00
79IVA14/02/2022 06:3014/02/2022 18:30
80IVA15/02/2022 06:3015/02/2022 18:30
81IVA15/02/2022 14:0015/02/2022 22:00
82IVA16/02/2022 06:3016/02/2022 18:30
83IVA16/02/2022 14:0016/02/2022 22:00
84IVA18/02/2022 18:3019/02/2022 06:30
85IVK14/02/2022 06:3014/02/2022 17:30
86IVK15/02/2022 06:3015/02/2022 18:30
87IVK16/02/2022 06:3016/02/2022 18:30
88JAD04/02/2022 22:0005/02/2022 06:00
89JAD14/02/2022 07:0014/02/2022 15:00
90JOS14/02/2022 07:3014/02/2022 15:30
91JOS15/02/2022 07:3015/02/2022 15:30
92JOS16/02/2022 07:3016/02/2022 15:30
93JOV14/02/2022 07:3014/02/2022 15:30
94JOV15/02/2022 07:3015/02/2022 15:30
95JOV16/02/2022 07:3016/02/2022 15:30
96KAS04/02/2022 22:0005/02/2022 06:00
97KAS14/02/2022 06:3014/02/2022 18:30
98KAS15/02/2022 06:3015/02/2022 18:30
99KAS16/02/2022 06:3016/02/2022 18:30
100KNE04/02/2022 22:0005/02/2022 06:00
101KNE14/02/2022 06:3014/02/2022 18:30
102KNE15/02/2022 06:3015/02/2022 18:30
103KNE16/02/2022 06:3016/02/2022 18:30
104KOL02/02/2022 14:0002/02/2022 22:00
105KOL04/02/2022 14:0004/02/2022 22:00
106KOL14/02/2022 06:0014/02/2022 14:00
107KOL15/02/2022 06:0015/02/2022 14:00
108KOL16/02/2022 06:0016/02/2022 14:00
109KOL19/02/2022 06:0019/02/2022 14:00
110KRS04/02/2022 07:3004/02/2022 15:30
111KRS13/02/2022 14:3013/02/2022 22:30
112KRS14/02/2022 07:3014/02/2022 15:30
113KRS15/02/2022 07:3015/02/2022 15:30
114KRS16/02/2022 07:3016/02/2022 15:30
115KRU04/02/2022 22:0005/02/2022 06:00
116KRU14/02/2022 06:3014/02/2022 18:30
117KRU15/02/2022 06:3015/02/2022 18:30
118KRU16/02/2022 06:3016/02/2022 18:30
119KUZ14/02/2022 06:3014/02/2022 18:30
120KUZ15/02/2022 06:3015/02/2022 18:30
121LIT04/02/2022 22:0005/02/2022 06:00
122LIT14/02/2022 06:3014/02/2022 18:30
123LIT15/02/2022 06:3015/02/2022 18:30
124LIT16/02/2022 06:3016/02/2022 18:30
125LUK19/02/2022 18:3020/02/2022 02:30
126MAH13/02/2022 14:3013/02/2022 22:30
127MAH14/02/2022 14:3014/02/2022 23:30
128MAH15/02/2022 14:3015/02/2022 23:30
129MAH16/02/2022 14:3016/02/2022 23:30
130MAR04/02/2022 22:0005/02/2022 06:00
131MAR04/02/2022 22:0005/02/2022 06:00
132MAR14/02/2022 06:0014/02/2022 14:00
133MAR14/02/2022 06:3014/02/2022 18:30
134MAR15/02/2022 06:0015/02/2022 14:00
135MAR15/02/2022 06:3015/02/2022 18:30
136MAR16/02/2022 06:3016/02/2022 18:30
137MAR19/02/2022 06:3019/02/2022 18:00
138MAR21/02/2022 06:0021/02/2022 14:00
139PAN14/02/2022 09:0014/02/2022 21:00
140PAN15/02/2022 14:3015/02/2022 23:30
141PAN16/02/2022 14:3016/02/2022 23:30
142PAN18/02/2022 18:3019/02/2022 06:30
143PAN19/02/2022 18:3019/02/2022 23:30
144PAV14/02/2022 14:3014/02/2022 23:30
145PAV15/02/2022 14:3015/02/2022 23:30
146PAV16/02/2022 14:3016/02/2022 23:30
147PAV18/02/2022 18:3019/02/2022 06:30
148PAV19/02/2022 18:3020/02/2022 02:30
149POL04/02/2022 22:0005/02/2022 06:00
150POL19/02/2022 06:3019/02/2022 18:00
151PRO13/02/2022 14:3013/02/2022 22:30
152RAD04/02/2022 22:0005/02/2022 06:00
153RAD13/02/2022 14:3013/02/2022 22:30
154RAD14/02/2022 09:0014/02/2022 21:00
155RAD14/02/2022 14:3014/02/2022 23:30
156RAD15/02/2022 14:3015/02/2022 23:30
157RAD15/02/2022 14:3015/02/2022 23:30
158RAD16/02/2022 14:3016/02/2022 23:30
159RAD18/02/2022 18:3019/02/2022 06:30
160RAD18/02/2022 18:3019/02/2022 06:30
161RAD19/02/2022 18:3019/02/2022 23:30
162RAD19/02/2022 18:3020/02/2022 02:30
163SHU04/02/2022 22:0005/02/2022 06:00
164SHU14/02/2022 06:3014/02/2022 18:30
165SHU15/02/2022 06:3015/02/2022 18:30
166SHU16/02/2022 06:3016/02/2022 16:30
167SKA04/02/2022 22:0005/02/2022 06:00
168SKA13/02/2022 02:3013/02/2022 11:00
169SKA14/02/2022 06:3014/02/2022 18:30
170SKA15/02/2022 06:3015/02/2022 18:30
171SKA16/02/2022 06:3016/02/2022 16:30
172SPA13/02/2022 14:3013/02/2022 22:30
173SPA14/02/2022 14:3014/02/2022 23:30
174SPA15/02/2022 14:3015/02/2022 23:30
175SPA18/02/2022 18:3019/02/2022 06:30
176STE14/02/2022 09:0014/02/2022 21:00
177STE15/02/2022 14:3015/02/2022 23:30
178STE18/02/2022 18:3019/02/2022 06:30
179STE19/02/2022 18:3019/02/2022 23:30
180STO04/02/2022 22:0005/02/2022 06:00
181STO14/02/2022 06:3014/02/2022 18:30
182STO15/02/2022 06:3015/02/2022 18:30
183STO16/02/2022 06:3016/02/2022 16:30
184STO18/02/2022 18:3019/02/2022 06:30
185STO19/02/2022 18:3019/02/2022 23:30
186STR04/02/2022 07:0004/02/2022 15:00
187STR14/02/2022 06:0014/02/2022 14:00
188STR15/02/2022 06:0015/02/2022 14:00
189STR16/02/2022 06:0016/02/2022 14:00
190STR19/02/2022 06:3019/02/2022 18:00
191TAJ04/02/2022 22:0005/02/2022 06:00
192TAJ14/02/2022 06:3014/02/2022 15:30
193TAJ15/02/2022 06:3015/02/2022 18:30
194TAJ16/02/2022 06:3016/02/2022 18:30
195TOM04/02/2022 22:0005/02/2022 06:00
196TOM14/02/2022 06:3014/02/2022 18:30
197TOM15/02/2022 06:3015/02/2022 18:30
198TOM16/02/2022 06:3016/02/2022 18:30
199TSV04/02/2022 22:0005/02/2022 06:00
200TSV13/02/2022 02:0013/02/2022 11:00
201TSV14/02/2022 06:3014/02/2022 18:30
202TSV15/02/2022 06:3015/02/2022 18:30
203TSV16/02/2022 06:3016/02/2022 18:30
204VAL04/02/2022 22:0005/02/2022 06:00
205VAL13/02/2022 02:0013/02/2022 11:00
206VAL14/02/2022 06:3014/02/2022 18:30
207VAL15/02/2022 14:0015/02/2022 22:00
208VAL16/02/2022 14:0016/02/2022 22:00
209VAL18/02/2022 18:3019/02/2022 06:30
210VIN14/02/2022 14:0014/02/2022 22:00
211VIN19/02/2022 06:3019/02/2022 18:00
212VIN21/02/2022 06:0021/02/2022 14:00
213VLA04/02/2022 22:0005/02/2022 06:00
214VLA13/02/2022 02:0013/02/2022 11:00
215VLA14/02/2022 06:3014/02/2022 18:30
216VLA15/02/2022 06:3015/02/2022 18:30
217VLA16/02/2022 06:3016/02/2022 18:30
218VLA19/02/2022 18:3020/02/2022 02:30
219VUK04/02/2022 07:3004/02/2022 15:30
220VUK14/02/2022 07:0014/02/2022 15:00
221VUK15/02/2022 07:0015/02/2022 14:00
222VUK16/02/2022 06:0016/02/2022 14:00
223VUK19/02/2022 06:3019/02/2022 18:00
224ZER13/02/2022 02:0013/02/2022 11:00
225ZER14/02/2022 06:3014/02/2022 18:30
226ZER15/02/2022 06:3015/02/2022 18:30
227ZER16/02/2022 06:3016/02/2022 18:30
228ZUL04/02/2022 06:3004/02/2022 16:30
229ZUL14/02/2022 09:0014/02/2022 21:00
230ZUL15/02/2022 14:3015/02/2022 23:30
231ZUL18/02/2022 18:3019/02/2022 06:30
232ZUL19/02/2022 18:3019/02/2022 23:30
233ZUN04/02/2022 22:0005/02/2022 06:00
234ZUN14/02/2022 14:0014/02/2022 22:00
H P D
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Hi,

I don't really understand your question, do you just want the hours per row?

Book3.xlsx
ABCD
1EMPLOYEESTART TIMEEND TIMEHours
2ACK2/2/22 10:00 PM2/3/22 10:00 AM12
3ACK2/4/22 10:00 PM2/5/22 6:00 AM8
4ACK2/14/22 6:30 AM2/14/22 6:30 PM12
5ACK2/15/22 6:30 AM2/15/22 6:30 PM12
6ACK2/16/22 6:30 AM2/16/22 4:30 PM10
7ATA2/2/22 10:00 PM2/3/22 10:00 AM12
8ATA2/4/22 10:00 PM2/5/22 6:00 AM8
9ATA2/14/22 6:30 AM2/14/22 6:30 PM12
10ATA2/15/22 6:30 AM2/15/22 6:30 PM12
11ATA2/16/22 6:30 AM2/16/22 6:30 PM12
12AUB2/2/22 10:00 PM2/3/22 10:00 AM12
Sheet1043
Cell Formulas
RangeFormula
D2:D12D2=(C2-B2)*24
 
Upvote 0
Hello,

I divided Worksheet data to steps to clarify my problem. Given data is StartTime and EndTime, Working Hours calculation per Working Day is straight forward.

Scenario: Calculate weekly Working Hours (Monday to Sunday) per calendar date and Monthly Working Hours per calendar month. As I mentioned in my initial post calendar week starts on Monday at 00.00 and ends on Sunday at 23.59.59, month of February starts on 01/02/2022 at 00:00 and ends on 28/02/2022 at 23:59:59.

Uploaded Worksheet contains February roster example for one employee.

Problem: When shift starts on 31/01/2022 at 18.00 and ends on 01/02/2022 at 06:00 we have 6 working hours in January and 6 working hours in February the latter should be included in February monthly working hours, it equally applies to shift on 28/02/2022 from 21:00 to 09:00 on 01/03/2022, when 3 working hours from 21:00 until midnight should be included in February working hours.
Similarly it is relevant to weekly working hours when shift starts on Sunday and ends on Monday. Sunday working hours should be included in the week ending at midnight and Monday working hours (after midnight) should be calculated to the following week.

Pivot table monthly working hours (or 7-day grouping starting Monday for weekly hours) presents data by starting date taking into account entire shift Ex. on 31/01/2022 12 working hours despite the fact
that actual working hours in January were 6.

Question: Aforementioned goal would be achieved with working hours calculation daily by calendar date (from 00:00 to 23:59:59). How to fulfill it?

EMPLOYEEWeekdaySTART TIMEEND TIMETime WorkedFebruary HoursWeekly Hours
ACKMonday
31/01/2022 18:00​
01/02/2022 06:00​
12.006.00
ACKTuesday
01/02/2022 22:00​
02/02/2022 06:00​
8.008.00
ACKThursday
03/02/2022 12:00​
03/02/2022 20:00​
8.008.00
ACKFriday
04/02/2022 12:00​
04/02/2022 20:00​
8.008.00
ACKSaturday
05/02/2022 12:00​
05/02/2022 20:00​
8.008.00
ACKSunday
06/02/2022 22:00​
07/02/2022 10:00​
12.0012.0050.00
ACKTuesday
08/02/2022 08:00​
08/02/2022 16:00​
8.008.00
ACKWednesday
09/02/2022 08:00​
09/02/2022 16:00​
8.008.00
ACKThursday
10/02/2022 08:00​
10/02/2022 16:00​
8.008.00
ACKFriday
11/02/2022 08:00​
11/02/2022 16:00​
8.008.00
ACKSunday
13/02/2022 22:00​
14/02/2022 10:00​
12.0012.0050.00
ACKTuesday
15/02/2022 10:00​
15/02/2022 18:00​
8.008.00
ACKWednesday
16/02/2022 10:00​
16/02/2022 18:00​
8.008.00
ACKThursday
17/02/2022 10:00​
17/02/2022 18:00​
8.008.00
ACKFriday
18/02/2022 10:00​
18/02/2022 18:00​
8.008.00
ACKSunday
20/02/2022 19:00​
21/02/2022 07:00​
12.0012.0049.00
ACKTuesday
22/02/2022 10:00​
22/02/2022 18:00​
8.008.00
ACKWednesday
23/02/2022 10:00​
23/02/2022 18:00​
8.008.00
ACKThursday
24/02/2022 10:00​
24/02/2022 18:00​
8.008.00
ACKFriday
25/02/2022 10:00​
25/02/2022 18:00​
8.008.00
ACKSaturday
26/02/2022 10:00​
26/02/2022 18:00​
8.008.00
ACKSunday
27/02/2022 18:00​
28/02/2022 06:00​
12.0012.0053.00
ACKMonday
28/02/2022 21:00​
01/03/2022 09:00​
12.003.00
 

Attachments

  • PivotWeek.png
    PivotWeek.png
    3.2 KB · Views: 18
Upvote 0
Thanks for clarifying, it helps a bit.
Your expected results in your Weekly Hours column seems incorrect, the last 3 totals don't add up.
This is what I have, hope it helps:

Book3.xlsx
ABCDEFG
1EMPLOYEEWeekdaySTART TIMEEND TIMETime WorkedFebruary HoursWeekly Hours
2ACKMonday1/31/22 18:002/1/22 6:00126 
3ACKTuesday2/1/22 22:002/2/22 6:0088 
4ACKThursday2/3/22 12:002/3/22 20:0088 
5ACKFriday2/4/22 12:002/4/22 20:0088 
6ACKSaturday2/5/22 12:002/5/22 20:0088 
7ACKSunday2/6/22 22:002/7/22 10:00121250
8ACKTuesday2/8/22 8:002/8/22 16:0088 
9ACKWednesday2/9/22 8:002/9/22 16:0088 
10ACKThursday2/10/22 8:002/10/22 16:0088 
11ACKFriday2/11/22 8:002/11/22 16:0088 
12ACKSunday2/13/22 22:002/14/22 10:00121244
13ACKTuesday2/15/22 10:002/15/22 18:0088 
14ACKWednesday2/16/22 10:002/16/22 18:0088 
15ACKThursday2/17/22 10:002/17/22 18:0088 
16ACKFriday2/18/22 10:002/18/22 18:0088 
17ACKSunday2/20/22 19:002/21/22 7:00121244
18ACKTuesday2/22/22 10:002/22/22 18:0088 
19ACKWednesday2/23/22 10:002/23/22 18:0088 
20ACKThursday2/24/22 10:002/24/22 18:0088 
21ACKFriday2/25/22 10:002/25/22 18:0088 
22ACKSaturday2/26/22 10:002/26/22 18:0088 
23ACKSunday2/27/22 18:002/28/22 6:00121252
24ACKMonday2/28/22 21:003/1/22 9:00123 
Sheet1043
Cell Formulas
RangeFormula
F2:F24F2=IF(OR(YEAR(C2)<YEAR(D2),MONTH(C2)<MONTH(("1/"&LEFT(F$1,FIND(" ",F$1)))+0)),HOUR(D2),IF(OR(YEAR(D2)>YEAR(C2),MONTH(D2)>MONTH(("1/"&LEFT(F$1,FIND(" ",F$1)))+0)),24-HOUR(C2),(D2-C2)*24))
G2:G24G2=IF(B2="Sunday",SUM(F$2:F2)-SUM(G$1:G1),"")
 
Upvote 0
Hello,

I suggest to look at this thread:

Regards,
Bernd
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top