How to split hours worked into 3 shift patterns?

JoeGraf10

New Member
Joined
Jul 26, 2022
Messages
6
Office Version
  1. 2021
  2. 2019
Platform
  1. Windows
Hello,
I have a time sheet scenario with 3 x shifts that are charged at different premiums. I have classified them as following:
Morning = midnight until 8am - 0:00 to 8:00
Day = 8am til 8pm - 8:00 to 20:00
Night = 8pm til midnight - 20:00 to 24:00

I have created a small table to the side to distinguish the time splits in the day. Eg, 08:00/20:00/24:00 to allot me to =if(start time<08:00,8:00-start time)*24,0) with the start time being 06:00 this works and returns 2 hours.

Not I need to portion out the day shift part of the hours worked say the end time is 21:00, it should then show 12 hours worked between 08:00 and 20:00, and then 1 hour from 20:00 to 21:00.

I have tried a couple "IFS" to try to portion this out and in my head the formula is perfect (it's not) haha

How would you superior excel users work this one out?

Thank you for your help 🙏
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Map1
ABCDEF
10:00
28:00
320:00
424:00:00
5
6
7
8startendshift1shift2shift3total
96:305:307:0012:004:0023:00
Blad1
Cell Formulas
RangeFormula
C9C9=IF(COUNT($A9:$B9)=2,MAX(0,MIN($A$2,$B9+($B9<$A9))-MAX($A9,$A$1))+MAX(0,MIN($A$2+1,$B9+($B9<$A9))-1),"")
D9D9=IF(COUNT($A9:$B9)=2,MAX(0,MIN($A$3,$B9+($B9<$A9))-MAX($A9,$A$2)),"")
E9E9=IF(COUNT($A9:$B9)=2,MAX(0,MIN($A$4,$B9+($B9<$A9))-MAX($A9,$A$3)),"")
F9F9=IF(COUNT($A9:$B9)=2,$B9-$A9+($B9<$A9),"")
 
Upvote 0
Amazing, I will give it a go shortly

Appreciate your time 👏
 
Upvote 0
Worked perfectly, thank you for the help!

Add on if you have the time....

The columns filled in by the employee is a column for date and also the start and finish time. Special rates apply to Sunday and also Bank Holidays, so I have created a column that identifies If the date is Sun, Mon, Tues etc etc and also another column for if the date mentioned is a bank holiday (yes/no is returned)

Is there an extention that could be added to the formulas you have created under Shift 1, 2 & 3 columns to exclude or Zero the hours in those shifts that relate to Sunday or bank holiday? The hours are already auto filled into columns "sunday" or "bank holiday"

Thank you
Joe
 
Upvote 0
like this ?
Cell Formulas
RangeFormula
B9:B31B9=IF(WEEKDAY(A9,2)=7,"Sunday",IF(ISNUMBER(MATCH(A9,TBL_Holidays[my Holidays],0)),"Holiday",""))
E9:E31E9=IF(AND([@special]="",COUNT($C9:$D9)=2),MAX(0,MIN($C$2,$D9+($D9<$C9))-MAX($C9,$C$1))+MAX(0,MIN($C$2+1,$D9+($D9<$C9))-1),"")
F9:F31F9=IF(AND([@special]="",COUNT($C9:$D9)=2),MAX(0,MIN($C$3,$D9+($D9<$C9))-MAX($C9,$C$2)),"")
G9:G31G9=IF(AND([@special]="",COUNT($C9:$D9)=2),MAX(0,MIN($C$4,$D9+($D9<$C9))-MAX($C9,$C$3)),"")
H9:H31H9=IF(AND([@special]<>"",COUNT($C9:$D9)=2),$D9-$C9+($D9<$C9),"")
I9:I31I9=IF(COUNT($C9:$D9)=2,$D9-$C9+($D9<$C9),"")
A10:A31A10=+A9+1
M3:M27M3=+M2+3
 
Upvote 0
From a glance at the set up that's exactly how I have my set up! 👏

I will re run tomorrow morning first thing and let you know how I get on!

Thank you Bsalv you Excel God
 
Upvote 0
i tried to use your formulas but it wasnt quite working so i have re jigged it and now in Shift1 to Shift 3, like yesterday i need them to say 0:00 if there was a value in either the Sunday or Special Column. this is what is currently in there which is perfect for the splitting of the shifts:

=IF(COUNT($F15:$G15)=2,MAX(0,MIN($R$5,$G15+($G15<$F15))-MAX($F15,$R$4)),"")

was thinking of adding "somehow" (the above, then IF value in the Sunday column is greater than zero, return Zero hours if it is and if it isnt, do nothing & IF value in the Special column is greater than zero, return Zero hours if it is and if it isnt, do nothing)

what are your thoughts??

thank you

Timesheet Screenshot.PNG
 
Upvote 0
for your 3 shift, the formula like in my E:G = if that column "Sunday or Special"=0 AND both start and stop are known then calculate the 3 shifts
Rich (BB code):
=IF(AND([@Sunday or Special]=0,COUNT($C9:$D9)=2),MAX(0,.......

then the Sunday-column = IF([@Sunday or Special]="Sunday",[@Duration],0)
The Special-column = IF([@Sunday or Special]="Special",[@Duration],0)

if you have problems, add a link to your file
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,207
Members
452,618
Latest member
Tam84

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