Calculate Total hours spanning midnight. Separate weekday, Saturday and Sunday hours - NO NIGHT SHIFT

kayte83

New Member
Joined
Sep 5, 2022
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hi, i am trying to calculate total weekday, Saturday and Sunday Hours. Each shift spans midnight. I can not find this anywhere, all similar posts include night shift. Night shift is irrelevant for me.

This is what I have so far, however I can't work out how to separate the hours after midnight.
DayDateStartEndWeekdaySaturdaySundayTotal
Saturday09/03/2216:008:00016016
Sunday09/04/2218:008:00001414
Monday09/05/221:008:007007
Tuesday09/06/2219:308:0012.50012.5
Wednesday09/07/2216:008:00160016
Thursday09/08/2220:008:00120012
Friday09/09/2221:008:00110011
Saturday09/10/2219:008:00013013
Sunday09/11/2217:308:000014.514.5
Monday09/12/2216:008:00160016
Tuesday09/13/2220:008:00120012
Wednesday09/14/2220:158:0011.750011.75
Total98.252928.5

E2 =MOD(End-Start,1)*24*(WEEKDAY(Date,2)<6)
F2 =MOD(End-Start,1)*24*(WEEKDAY(Date,2)=6)
G2 =(MOD(End-Start,1)*24*(WEEKDAY(Date,2)=7))


Below is what I would love to achieve with formulas.

DayDateStartEndWeekdaySaturdaySundayTotal
Saturday09/03/2216:008:0008816
Sunday09/04/2218:008:0080614
Monday09/05/221:008:007007
Tuesday09/06/2219:308:0012.50012.5
Wednesday09/07/2216:008:00160016
Thursday09/08/2220:008:00120012
Friday09/09/2221:008:0038011
Saturday09/10/2219:008:0005813
Sunday09/11/2217:308:00806.514.5
Monday09/12/2216:008:00160016
Tuesday09/13/2220:008:00120012
Wednesday09/14/2220:158:0011.750011.75
Total98.252928.5

Any help would be greatly appreciated. This has almost broken me.
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
See if the following formulas work for you:
Excel Formula:
=24*IF(D2>C2,(D2-C2)*(WEEKDAY(B2,2)<6),(1-C2)*(WEEKDAY(B2,2)<6)+D2*(WEEKDAY(B2+1,2)<6))
=24*IF(D2>C2,(D2-C2)*(WEEKDAY(B2,2)=6),(1-C2)*(WEEKDAY(B2,2)=6)+D2*(WEEKDAY(B2+1,2)=6))
=24*IF(D2>C2,(D2-C2)*(WEEKDAY(B2,2)=7),(1-C2)*(WEEKDAY(B2,2)=7)+D2*(WEEKDAY(B2+1,2)=7))
 
Upvote 0
This is Brilliant. Thank you.

Now I have been asked to add a public holiday column... Is it possible to do this with a "datevalue" formula? I have been playing around with it for too long now, I am thinking it may not even be possible?
 
Upvote 0
See if the following formulas work for you:

Cell E2 (Weekday) =24*MOD(D2-C2,1)-SUM(F2:H2)
Cell F2 (Saturday) =24*IF(D2>C2,(D2-C2)*(WEEKDAY(B2,2)=6),(1-C2)*(WEEKDAY(B2,2)=6)+D2*(WEEKDAY(B2+1,2)=6))
Cell G2 (Sunday) =24*IF(D2>C2,(D2-C2)*(WEEKDAY(B2,2)=7),(1-C2)*(WEEKDAY(B2,2)=7)+D2*(WEEKDAY(B2+1,2)=7))
Cell H2 (Holiday) =24*IF(D2>C2,(D2-C2)*ISNUMBER(MATCH(B2,Holidays,0)),(1-C2)*ISNUMBER(MATCH(B2,Holidays,0))+D2*ISNUMBER(MATCH(B2+1,Holidays,0)))
where Holidays is a named range that contains holiday dates -- no Saturdays or Sundays.
 
Upvote 0
Thank you again for your reply. Unfortunately there are holidays on Saturdays and Sundays that need to be included. :(
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,306
Members
452,633
Latest member
DougMo

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