Time Calculation Based on Shift Pattern

Koza84

New Member
Joined
Mar 26, 2017
Messages
31
Hello,

I try to find formula in column C to calculate time based on shift patterns that could be different. Sometimes shifts can be 8 hours per day, or it can be day off in the middle of the week, because of bank holiday.

Please see below data.

in column C are results.
C2= 13.5 hours, because 7.5 h was worked Monday and 6 hours Tuesday, based on shift times in column E:F
C3= 3.5 hours, because 3.5 h was worked Tuesday , based on shift times in column E:F
C4= 1 hour, because 0.5 h was worked Tue and 0.5 hours Wed, based on shift times in column E:F
C5= 8 hours, because 7.5 h was worked Wed, 0 hours Thursday as it was day off (that's why i have made start/end time on that date same) and 0.5 hour Fri, based on shift times in column E:F
C6= 13.25 hours, because 7.5 h was worked Fri and 5.75 hours Sat, based on shift times in column E:F

Any help is greatly appreciated.

Best regards

A B C E F
Start TimeEnd TimeHoursShift StartShift End
Mon 10-Dec-18 08:30Tue 11-Dec-18 12:0013.5Mon 10-Dec-18 08:00Mon 10-Dec-18 16:00
Tue 11-Dec-18 12:00Tue 11-Dec-18 15:303.5Tue 11-Dec-18 06:00Tue 11-Dec-18 16:00
Tue 11-Dec-18 15:30Wed 12-Dec-18 08:301Wed 12-Dec-18 08:00Wed 12-Dec-18 16:00
Wed 12-Dec-18 08:30Fri 14-Dec-18 06:308Thu 13-Dec-18 06:00Thu 13-Dec-18 06:00
Fri 14-Dec-18 06:30Sat 15-Dec-18 11:4513.25Fri 14-Dec-18 06:00Fri 14-Dec-18 16:00
Sat 15-Dec-18 06:00Sat 15-Dec-18 12:00
Sun 16-Dec-18 06:00Sun 16-Dec-18 06:00

<tbody>
</tbody>
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Apologies for bumbing it again but still looking for solution. Is the result not possible to achieve ?
 
Upvote 0
Hi there.

Is it not possible to achieve results or is my approach not right?

Best regards
 
Upvote 0
Good Morning All

I wonder if I have explained results well?

Is the solution to complex to achieve?

Please any let me know maybe I should try different approach?

Best regards
 
Upvote 0
Hi.

Stil trying to fine solution.

Could anyone provide any feedback at all?

Best regards
 
Upvote 0
I cannot help you with the layout you presented because I think it's confusing. I mean, let's look at this shift pattern:

Mon 10-Dec-18 08:30 Tue 11-Dec-18 12:00

In fact these are 2 shifts:

Mon 10-Dec-18 08:30 till Mon 10-Dec-18 16:00
Tue 11-Dec-18 06:00 till Tue 11-Dec-18 12:00

However, I can help you with another layout. When you are stuck with a fixed layout you probably get from work then you can stop reading.

Row\Col
A​
B​
C​
D​
E​
F​
G​
H​
1​
DayDateStartTimeEndTimeHours
ShiftStart
ShiftEnd
2​
Monday
10-12-2018​
8:30​
16:00​
7,50​
6:00​
16:00​
3​
Tuesday
11-12-2018​
6:00​
12:00​
6,00​
4​
Tuesday
11-12-2018​
12:00​
15:30​
3,50​
5​
Tuesday
11-12-2018​
15:30​
16:00​
0,50​
6​
Wednesday
12-12-2018​
8:00​
8:30​
0,50​
7​
Wednesday
12-12-2018​
8:30​
16:00​
7,50​
8​
Friday
14-12-2018​
6:00​
6:30​
0,50​
9​
Friday
14-12-2018​
6:30​
16:00​
9,50​
10​
Saturday
15-12-2018​
6:00​
11:45​
5,75​

Formula in E2:
Code:
=IF(AND(WEEKDAY(B2;2)<>4;WEEKDAY(B2;2)<>7);IF(SUM(MAX(($H$2-$G$2-MAX(0;C2-$G$2)-MAX(0;$H$2-D2))*24;0);MAX(($P$4-$O$4-MAX(0;C2-$O$4)-MAX(0;$P$4-D2))*24;0))=0;"";SUM(MAX(($H$2-$G$2-MAX(0;C2-$G$2)-MAX(0;$H$2-D2))*24;0);MAX(($P$4-$O$4-MAX(0;C2-$O$4)-MAX(0;$P$4-D2))*24;0)));"")
And drag down. (Replace semi-colon with comma if you are USA).

The formula first looks at the weekday. If it's NOT a Thursday or Sunday then continue (because these are your days off).
The Weekday has 2 parameters: serial_number (which is the date) and return_type (which is a number and refers to start of week). I chose to start at Monday which is represented by yhe number 2.
 
Upvote 0

Forum statistics

Threads
1,214,415
Messages
6,119,375
Members
448,888
Latest member
Arle8907

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