Overlap between two time ranges

sae1984

New Member
Joined
Jun 18, 2021
Messages
5
Office Version
  1. 2013
Platform
  1. Windows
Hi I have three columns A, B , C, where A has number of days, B has a starting time and C has and end time

Day3
07:23:43​
16:27:01​
Day2
19:28:33​
20:09:55​
Day2
09:00:33​
19:13:55​
Day5
08:00:03​
16:03:23​

I want to check if one time range (from starting time to end time, B-C) overlaps nay of the other time ranges in the specific day, and how many times. Because this is a sample of data and possibly columns b and c will be larger.

Thanks a lot
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Welcome to MrExcel!

Try:

Book1
ABCD
1DayStartEndOverlaps
2Day37:23:4316:27:010
3Day219:28:3320:09:551
4Day29:00:3319:13:550
5Day58:00:0316:03:230
6Day219:30:0119:31:021
7Day713:00:0013:01:000
8Day714:00:0014:01:001
9Day713:59:0014:00:301
10
Sheet2
Cell Formulas
RangeFormula
D2:D9D2=SUM(IF(A$2:A$20=A2,IF(IF(C2<C$2:C$20,C2,C$2:C$20)-IF(B2>B$2:B$20,B2,B$2:B$20)>0,1)))-1
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Hi Everyone and @Eric W

I have a similar question.

I have to identify overlapping times. Tried an INDEX MATCH and my formulation didn't work. Also, an IF function but get SPILL Error in columns L & O.

What I need:
If both columns E & I match the respective row, I need to check for overlapping times in columns J & K for the time range in the respective row and put a 1 or "Yes" as an identifier. I want all rows with overlapping times identified.

The original raw data is in Columns A - C in case you'd like to rework the Start and End Dates. Note that if a shift starts in PM and Ends in AM in Column C, it's the next day as the date in Column B is the "Start Date" essentially.

Thank you in advance!
Aya Listing.xlsx
ABCDEFGHIJKLMNO
1NameDateShiftPerson + Date + ShiftPerson + Start DateOTypeTypeEnd DatePerson + End DateStart TimeEnd TimeStart Time Overlap Index?Start Time Overlap IFEnd Time Overlap Index?Start Time Overlap IF
2Person One 1/28/202107:00 PM-07:30 PMPerson One 4422407:00 PM-07:30 PMPerson One 442241Something1/28/2021Person One 4422419:0019:304.0005.000
3Person One 1/28/202112:00 PM-07:00 PMPerson One 4422412:00 PM-07:00 PMPerson One 442241Something1/28/2021Person One 4422412:0019:004.0004.000
4Person One 1/28/202107:00 AM-07:30 PMPerson One 4422407:00 AM-07:30 PMPerson One 442241Something1/28/2021Person One 442247:0019:305.0015.000
5Person One 1/28/202107:00 AM-07:30 PMPerson One 4422407:00 AM-07:30 PMPerson One 442241Something1/28/2021Person One 442247:0019:305.0015.000
6Person One 1/28/202107:00 AM-12:00 PMPerson One 4422407:00 AM-12:00 PMPerson One 442241Something1/28/2021Person One 442247:0012:005.0004.000
7Person Two 1/28/202111:30 AM-07:00 PMPerson Two 4422411:30 AM-07:00 PMPerson Two 442241Something1/28/2021Person Two 4422411:3019:005.00#SPILL!5.00#SPILL!
8Person Two 1/28/202107:00 AM-07:00 PMPerson Two 4422407:00 AM-07:00 PMPerson Two 442241Something1/28/2021Person Two 442247:0019:005.005.00
9Person Two 1/28/202107:00 AM-07:00 PMPerson Two 4422407:00 AM-07:00 PMPerson Two 442241Something1/28/2021Person Two 442247:0019:005.005.00
10Person Two 1/28/202107:00 AM-11:30 AMPerson Two 4422407:00 AM-11:30 AMPerson Two 442241Something1/28/2021Person Two 442247:0011:305.005.00
11Person Three 1/21/202106:45 PM-12:00 AMPerson Three 4421706:45 PM-12:00 AMPerson Three 442171Something1/21/2021Person Three 4421718:450:005.00FALSE5.00FALSE
12Person Three 1/21/202107:15 AM-07:30 AMPerson Three 4421707:15 AM-07:30 AMPerson Three 442171Something1/21/2021Person Three 442177:157:305.00FALSE5.00FALSE
13Person Three 1/21/202112:00 AM-07:15 AMPerson Three 4421712:00 AM-07:15 AMPerson Three 442171Something1/21/2021Person Three 442170:007:155.00FALSE5.00FALSE
Sheet7
Cell Formulas
RangeFormula
D2:D13D2=A2&B2&C2
E2:E13E2=A2&B2
H2:H13H2=IF(AND(MID(C2,7,2)="PM",RIGHT(C2,2)="AM",(MID(C2,10,2)*1)<12)=TRUE,B2+1,B2)
I2:I13I2=A2&H2
J2:J13J2=LEFT(C2,8)+12
K2:K13K2=RIGHT(C2,8)+12
L2:L13L2=MATCH(1,($E$2:$E$6=E2)*($I$2:$I$6=I2)*($J$2:$J$6<J2)*($K$2:$K$6>J2))
M11:M15,M2:M7M2=IF($E$2:$E$6=E2,IF($I$2:$I$6=I2,IF($J$2:$J$6<J2,IF($K$2:$K$6>J2,1,0),0)))
O11:O15,O2:O7O2=IF($E$2:$E$6=E2,IF($I$2:$I$6=I2,IF($J$2:$J$6<K2,IF($K$2:$K$6>K2,1,0),0)))
N2:N13N2=MATCH(1,($E$2:$E$6=E2)*($I$2:$I$6=I2)*($J$2:$J$6<K2)*($K$2:$K$6>K2))
Dynamic array formulas.
 
Upvote 0
Your formulas are kind of all over the place. I'd definitely rework your layout. But on the shift range column (C), is a shift of 07:00 PM-07:30 PM a .5 hour shift, or a 24.5 hour shift? Same question, line 12. Is there a minimum number of hours for a shift?
 
Upvote 0
Assuming each shift must be at least 3 hours:

Book1
ABCDEFGH
1NameDateShiftOTypeTypeStartEndOverlap?
2Person One 1/28/202107:00 PM-07:30 PM1Something1/28/21 7:00 PM1/29/21 7:30 PMTRUE
3Person One 1/28/202112:00 PM-07:00 PM1Something1/28/21 12:00 PM1/28/21 7:00 PMTRUE
4Person One 1/28/202107:00 AM-07:30 PM1Something1/28/21 7:00 AM1/28/21 7:30 PMTRUE
5Person One 1/28/202107:00 AM-07:30 PM1Something1/28/21 7:00 AM1/28/21 7:30 PMTRUE
6Person One 1/28/202107:00 AM-12:00 PM1Something1/28/21 7:00 AM1/28/21 12:00 PMTRUE
7Person Two 1/28/202111:30 AM-07:00 PM1Something1/28/21 11:30 AM1/28/21 7:00 PMTRUE
8Person Two 1/28/202107:00 AM-07:00 PM1Something1/28/21 7:00 AM1/28/21 7:00 PMTRUE
9Person Two 1/28/202107:00 AM-07:00 PM1Something1/28/21 7:00 AM1/28/21 7:00 PMTRUE
10Person Two 1/28/202107:00 AM-11:30 AM1Something1/28/21 7:00 AM1/28/21 11:30 AMTRUE
11Person Three 1/21/202106:45 PM-12:00 AM1Something1/21/21 6:45 PM1/22/21 12:00 AMTRUE
12Person Three 1/21/202107:15 AM-07:30 AM1Something1/21/21 7:15 AM1/22/21 7:30 AMTRUE
13Person Three 1/21/202112:00 AM-07:15 AM1Something1/21/21 12:00 AM1/21/21 7:15 AMFALSE
Sheet8
Cell Formulas
RangeFormula
F2:F13F2=B2+LEFT(C2,8)
G2:G13G2=B2+RIGHT(C2,8)+(RIGHT(C2,8)+0<LEFT(C2,8)+0.125)
H2:H13H2=SUM(--(IF((A2=$A$2:$A$13)*(ROW(A2)<>ROW($A$2:$A$13)),IF(G2<$G$2:$G$13,G2,$G$2:$G$13)-IF(F2>$F$2:$F$13,F2,$F$2:$F$13),0)>0))>0
 
Upvote 0
Your formulas are kind of all over the place. I'd definitely rework your layout. But on the shift range column (C), is a shift of 07:00 PM-07:30 PM a .5 hour shift, or a 24.5 hour shift? Same question, line 12. Is there a minimum number of hours for a shift?
Hi @Eric W

There is no minimum number of hours per shift and there are no shifts for 24 hours or more.
 
Upvote 0
In that case, change the G2 formula to:

=B2+RIGHT(C2,8)+(RIGHT(C2,8)+0<LEFT(C2,8)+0)
 
Upvote 0
In that case, change the G2 formula to:

=B2+RIGHT(C2,8)+(RIGHT(C2,8)+0<LEFT(C2,8)+0)
@Eric W

The fornula seems to work so thank you for your help!

The issue I have now is that it seems to crash my Excel using it with a range with 90,000+ rows even with "calculate threads" enabled.

By any chance, is there an alternative that can handle such large range? I need to use this with other data sets with over 100,000 rows.

Sorry for not mentioning the large data sets I'm working with before.

I'll check Power Query to see if I can find something on that end but prefer an Excel function, if possible.
 
Upvote 0

Forum statistics

Threads
1,214,858
Messages
6,121,956
Members
449,057
Latest member
FreeCricketId

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