How to Split Shifts into Day/Night, Weekends

WaheedIqbal

New Member
Joined
Jun 5, 2018
Messages
5
Dear Excel experts,

I am required to make payroll payment to few (10-15) employees working in Security industry (Shift workers). The pays are determined by the timings of the shift i.e different rates of pay for Day shift (06:00 to 18:00), night shift (06:00 to 18:00), Saturday (24 hrs) and Sunday (24 hrs).

Please see sample data from the manual working i have done:
DateShiftStart TimeFinish TimeHoursDayNightSatSun
14-03-18Wednesday20:000:00 4.00 4
16-03-18

<tbody>
</tbody>
Friday

<tbody>
</tbody>
22:00

<tbody>
</tbody>
2:15

<tbody>
</tbody>
4.25

<tbody>
</tbody>
2

<tbody>
</tbody>
2.25

<tbody>
</tbody>
17-03-18

<tbody>
</tbody>
Saturday

<tbody>
</tbody>
15:00

<tbody>
</tbody>
4:30

<tbody>
</tbody>
13.50

<tbody>
</tbody>
9

<tbody>
</tbody>
4.5

<tbody>
</tbody>

<colgroup><col><col><col><col><col><col span="4"></colgroup><tbody>
</tbody>

The first four columns is what i get from my operations team and i then manually split the shifts into Day/Night/Sat/Sun.

Is there a way that this can be automated?

Many thanks for your help.

Regards,

Waheed
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Hi Waheed, and welcome to MrExcel,

Take a look at this and see if this helps:


Book1
ABCDEFGHIJKLMN
1DateShiftStart TimeFinish TimeHoursDayNightSatSunDay Shift06:00:0018:00:00
214-Mar-18Wednesday20:0000:004,00-4,0000
316-Mar-18Friday22:0002:154,25-4,2500
417-Mar-18Saturday15:0004:3013,50--13,50
Sheet1
Cell Formulas
RangeFormula
E2=SUM(F2:I2)
F2=IFERROR(((NETWORKDAYS.INTL((A2+C2),(IF(D2)+D2),"0000011",)-1)*($M$1-$L$1)+IF(NETWORKDAYS.INTL((IF(D2)+D2),(IF(D2)+D2),"0000011"),MEDIAN(MOD((IF(D2)+D2),1),$M$1,$L$1),$M$1)-MEDIAN(NETWORKDAYS.INTL((A2+C2),(A2+C2),"0000011")*MOD((A2+C2),1),$M$1,$L$1))*24,0)
G2=IF(WEEKDAY(A2,2)<6,(((A2+D2)-(A2+C2)+((A2+D2)<(A2+C2)))*24)-F2,0)
H2=IF(WEEKDAY(A2,2)=6,(((A2+D2)-(A2+C2)+((A2+D2)<(A2+C2)))*24),0)
I2=IF(WEEKDAY(A2,2)=7,(((A2+D2)-(A2+C2)+((A2+D2)<(A2+C2)))*24),0)
 
Upvote 0
Hi Joris

Thank you for your time and apologies for a delayed response.

I have tried the above and got following results: (sorry couldn't figure out how to paste excel sheet)

DateShiftStart TimeFinish TimeHoursDayNightSatSunday
11-05-18Friday22:002:004-222600
12-05-18Saturday23:003:0040040
11-05-18Friday22:002:004-222600
13-05-18Sunday0:004:304.50004.5
12-05-18Saturday23:003:0040040
09-05-18Wednesday20:001:155.25-18.752400
11-05-18Friday21:001:454.75-2125.7500
12-05-18Saturday21:004:157.25007.250
12-05-18Saturday22:003:0050050


<colgroup><col><col><col span="7"></colgroup><tbody>
</tbody>

As you can see, some adjustment to formula is required. the first row result should have been 2 hours under Friday and 2 under Saturday (changed from Friday to Saturday after midnight). Similarly, 2nd row result should have been 1 hour Saturday and 3 hour sunday. Can you please have a look.

Also I have client and employee name in first two columns A & B of the sheet. Can you please adjust the formulas for this.

Hope i have been able to explain. Many thanks again for your help.
Much appreciated.
 
Upvote 0
Hi,

try this:

Book1
CDEFGHIJKLMNO
1DateShiftStart TimeFinish TimeHoursDayNightSatSunDay Shift06:00:0018:00:00
211-5-2018Friday22:0002:004,000,002,002,000,00Sat/Sun00:00:0000:00:00
312-5-2018Saturday23:0003:004,000,000,001,003,00
411-5-2018Friday22:0002:004,000,002,002,000,00
513-5-2018Sunday00:0004:304,500,000,000,004,50
612-5-2018Saturday23:0003:004,000,000,001,003,00
79-5-2018Wednesday20:0001:155,250,005,250,000,00
811-5-2018Friday21:0001:454,750,003,001,750,00
912-5-2018Saturday21:0004:157,250,000,003,004,25
1012-5-2018Saturday22:0003:005,000,000,002,003,00
Sheet1
Cell Formulas
RangeFormula
H2=IFERROR(((NETWORKDAYS.INTL((C2+E2),(C2+(F2)+F2),"0000011",)-1)*($O$1-$N$1)+IF(NETWORKDAYS.INTL((IF(F2)+F2),(IF(F2)+F2),"0000011"),MEDIAN(MOD((IF(F2)+F2),1),$O$1,$N$1),$O$1)-MEDIAN(NETWORKDAYS.INTL((C2+E2),(C2+E2),"0000011")*MOD((C2+E2),1),$O$1,$N$1))*24,0)
I2=IF(WEEKDAY(C2,2)<6,(((C2+IF(AND(WEEKDAY(C2,2)=5,F2),$O$2,F2))-(C2+E2)+((C2+IF(AND(WEEKDAY(C2,2)=5,F2),$O$2,F2))<(C2+E2)))*24)-H2,0)
J2=IFERROR(((NETWORKDAYS.INTL((C2+E2),(IF(F2)+F2),"1111101")-1)*($O$2-$N$2)+IF(NETWORKDAYS.INTL((IF(F2)+F2),(IF(F2)+F2),"1111101"),MEDIAN(MOD((IF(F2)+F2),1),$O$2,$N$2),$O$2)-MEDIAN(NETWORKDAYS.INTL((C2+E2),(C2+E2),"1111101")*MOD((C2+E2),1),$O$2,$N$2))*24,0)
K2=IFERROR(((NETWORKDAYS.INTL((C2+E2),(IF(F2)+F2),"1111110")-1)*($O$2-$N$2)+IF(NETWORKDAYS.INTL((IF(F2)+F2),(IF(F2)+F2),"1111110"),MEDIAN(MOD((IF(F2)+F2),1),$O$2,$N$2),$O$2)-MEDIAN(NETWORKDAYS.INTL((C2+E2),(C2+E2),"1111110")*MOD((C2+E2),1),$O$2,$N$2))*24,0)
 
Upvote 0
HI Mate

Got this result which still is not correct. the total actual hours in the first shift are 4 whereas the formula result is only under "Night". There should be 2 under Sat also. the result in 2nd row is 0 only.

DateShiftStart TimeFinish TimeActual HrsDayNightSaturdaySundayDay Shift6:00:0018:00
11-05-18Friday22:002:00 4.00 0200 Sat/Sun0:000:00
12-05-18Saturday23:003:00 4.00 0000
11-05-18Friday22:002:00 4.00 0200
13-05-18Sunday0:004:30 4.50 0000

<colgroup><col width="64" span="12" style="width:48pt"> </colgroup><tbody>
</tbody>

<colgroup><col width="64" span="13" style="width:48pt"> </colgroup><tbody>
</tbody>

Can you please have a look.

Thanks
 
Upvote 0
Hi,

taken a quick look but i don't see anything being off.
i redid my example and it's clearly showing 2 under saturday in cell J2.
So don't know what you've did wrong but you didn't copy my formula exactly.

CDEFGHIJKLMNO
1DateShiftStart TimeFinish TimeHoursDayNightSatSunDay Shift06:00:0018:00:00
211-5-2018Friday22:0002:00 4,00 - 2,00 2,00
- Sat/Sun00:00:0000:00:00
312-5-2018Saturday23:0003:00 4,00 - - 1,00 3,00
411-5-2018Friday22:0002:00 4,00 - 2,00 2,00 -
513-5-2018Sunday00:0004:30 4,50 - - - 4,50
612-5-2018Saturday23:0003:00 4,00 - - 1,00 3,00
79-5-2018Wednesday20:0001:15 5,25 - 5,25 - -
811-5-2018Friday21:0001:45 4,75 - 3,00 1,75 -
912-5-2018Saturday21:0004:15 7,25 - - 3,00 4,25
1012-5-2018Saturday22:0003:00 5,00 - - 2,00 3,00
1111-5-2018Friday08:0002:00 18,00 10,00 6,00 2,00 -

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1
 
Last edited:
Upvote 0
Hi Joris

Sorry to be a pain. Tried the exact copy of your screen shot and full copy paste of formulas. I am still getting problem with Saturday/Sunday. Do i need a specific format for the extra columns M, N and O you have inserted or may be AM/PM issue? Also is it possible we can exchange excel sheet?

Thanks
 
Upvote 0
Hi,

@jorismoerings,

Your formula in #4 don't gave me same result as is in your post.
For Sat and Sun I got only 0 (zero)
 
Upvote 0
@Ingolf @WaheedIqbal

Just hoping you both noticed the small differences in the formula for weekdays and saturday and sunday but assuming you did and subsequently assuming you've got the "analysis pack" which holds the "networkdays.intl" function turned on.

Just to check assumptions:
1. Can you confirm you've turned on the "analysis pack" to be abvle to use the NETWORKDAYS.INTL function
2. Can you share you're Excel version
3. Could you share a screenshot/or an example file with your attempts so i can take a look.
 
Upvote 0
@Ingolf @WaheedIqbal

Besides forementioned assumptions: there's a difference in the cell N2 and O2 which is important and i forgot to mention.

Can you do this check =O2=N2. If the result comes back with TRUE. Change O2 to =N2+1 and re-check the result of my formula.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,603
Members
449,038
Latest member
Arbind kumar

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