Add Time Overlap

hajiali

Well-known Member
Joined
Sep 8, 2018
Messages
624
Office Version
  1. 2016
Platform
  1. Windows
Hello All Im trying to find a way to calculate time overlaps.

ex;

If Agent Actual shift is 06:30-15:00 and agents wants to pickup another shift from14:00-22:30 excel calculates 1 hour over lap vise visa
or
If Agent Actual shift is 14:00-22:30 and agents wants to pickup another shift from 06:30-15:00 excel calculates 1 hour over lap

I can have start and end times of shift in one cell or I can also split the start and end times to 2 separate cells whichever would be easiest to calculate time overlap. I would like a non-array formula or VBA any suggestions is greatly appreciated. Let me know if I need to clarify anything.
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Try this
Solutions 20210719.003.xlsm
ABCDEF
1Shift 1Shift 2
2Start time End TimeStart time End TimeShift Overlap
3Agent A14:0022:301:00
4Agent A6:3015:001:00
5Agent B12:0017:002:00
6Agent B8:0014:002:00
7Agent C0:00
Time Overlap
Cell Formulas
RangeFormula
F3:F7F3=IF(SUMPRODUCT((($A$3:$A$7=A3)*($E$3:$E$7))-(($A$3:$A$7=A3)*($B$3:$B$7)))>=0,SUMPRODUCT((($A$3:$A$7=A3)*($E$3:$E$7))-(($A$3:$A$7=A3)*($B$3:$B$7))),0)
 
Upvote 0
thank you Crystalyzer for the reply Below is the scenario that I would have. I would need to check each row for the overlap as its for the same agent the actual shift and pickup shift. How would I get the same results. if shift does not have an overlap put the word GAP for that column. Hope this clarifies.

Shift 1Shift 2
Start timeEnd TimeStart timeEnd TimeShift Overlap
14:0022:306:3015:001:00
8:0014:0012:0017:002:00
8:0014:0014:0021:300:00
14:0022:304:0015:00GAP
 
Upvote 0
that simplifies things considerably

Solutions 20210719.003.xlsm
ABCDEF
1Shift 1Shift 2
2Start time End TimeStart time End TimeShift Overlap
3Agent A6:3015:0014:0022:301:00
4Agent B12:0017:00No Shift 2
5Agent C8:0012:0013:0017:00GAP
Time Overlap
Cell Formulas
RangeFormula
F3:F5F3=IFS(ISBLANK(D3),"No Shift 2",C3-D3>0,C3-D3,TRUE,"GAP")
 
Upvote 0
my version if Excel does not have the "ifs" function.
 
Upvote 0
Solutions 20210719.003.xlsm
ABCDEFG
1Shift 1Shift 2
2Start time End TimeStart time End TimeShift Overlap IFSShift Overlap IF
3Agent A6:3015:0014:0022:301:001:00
4Agent B12:0017:00No Shift 2No Shift 2
5Agent C8:0012:0013:0017:00GAPGAP
Time Overlap
Cell Formulas
RangeFormula
F3:F5F3=IFS(ISBLANK(D3),"No Shift 2",C3-D3>0,C3-D3,TRUE,"GAP")
G3:G5G3=IF(ISBLANK(D3),"No Shift 2",IF(C3-D3>0,C3-D3,"GAP"))
 
Upvote 0
Solution
Thank you so much for your hlep Crystalyzer based on what you gave me I was able to come up the the following Formula to do what I need. I had to write down all different scenarios to get it.

Excel Formula:
=IFERROR(IF(B1="OFF",0,IF(AND(B1>D1,B1-E1>0),0,IF(AND(B1<D1,D1-C1>0),0,IF(AND(D1<B1,B1<E1),E1-B1,IF(AND(B1<D1,D1<C1),C1-D1,0))))),0)
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

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