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

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Apologies for bumbing it again but still looking for solution. Is the result not possible to achieve ?
 
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
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.

[Table="width:, class:grid"][tr][td]Row\Col[/td][td]
A​
[/td][td]
B​
[/td][td]
C​
[/td][td]
D​
[/td][td]
E​
[/td][td]
F​
[/td][td]
G​
[/td][td]
H​
[/td][/tr][tr][td]
1​
[/td][td="bgcolor:#0070C0"]Day[/td][td="bgcolor:#0070C0"]Date[/td][td="bgcolor:#0070C0"]StartTime[/td][td="bgcolor:#0070C0"]EndTime[/td][td="bgcolor:#0070C0"]Hours[/td][td][/td][td="bgcolor:#0070C0"]
ShiftStart
[/td][td="bgcolor:#0070C0"]
ShiftEnd
[/td][/tr]
[tr][td]
2​
[/td][td]Monday[/td][td]
10-12-2018​
[/td][td]
8:30​
[/td][td]
16:00​
[/td][td]
7,50​
[/td][td][/td][td="bgcolor:#FFFF00"]
6:00​
[/td][td="bgcolor:#FFFF00"]
16:00​
[/td][/tr]
[tr][td]
3​
[/td][td]Tuesday[/td][td]
11-12-2018​
[/td][td]
6:00​
[/td][td]
12:00​
[/td][td]
6,00​
[/td][td][/td][td][/td][td][/td][/tr]
[tr][td]
4​
[/td][td]Tuesday[/td][td]
11-12-2018​
[/td][td]
12:00​
[/td][td]
15:30​
[/td][td]
3,50​
[/td][td][/td][td][/td][td][/td][/tr]
[tr][td]
5​
[/td][td]Tuesday[/td][td]
11-12-2018​
[/td][td]
15:30​
[/td][td]
16:00​
[/td][td]
0,50​
[/td][td][/td][td][/td][td][/td][/tr]
[tr][td]
6​
[/td][td]Wednesday[/td][td]
12-12-2018​
[/td][td]
8:00​
[/td][td]
8:30​
[/td][td]
0,50​
[/td][td][/td][td][/td][td][/td][/tr]
[tr][td]
7​
[/td][td]Wednesday[/td][td]
12-12-2018​
[/td][td]
8:30​
[/td][td]
16:00​
[/td][td]
7,50​
[/td][td][/td][td][/td][td][/td][/tr]
[tr][td]
8​
[/td][td]Friday[/td][td]
14-12-2018​
[/td][td]
6:00​
[/td][td]
6:30​
[/td][td]
0,50​
[/td][td][/td][td][/td][td][/td][/tr]
[tr][td]
9​
[/td][td]Friday[/td][td]
14-12-2018​
[/td][td]
6:30​
[/td][td]
16:00​
[/td][td]
9,50​
[/td][td][/td][td][/td][td][/td][/tr]
[tr][td]
10​
[/td][td]Saturday[/td][td]
15-12-2018​
[/td][td]
6:00​
[/td][td]
11:45​
[/td][td]
5,75​
[/td][td][/td][td][/td][td][/td][/tr]
[/table]


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,224,821
Messages
6,181,163
Members
453,021
Latest member
Justyna P

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