Calculate if any part of a time range is within another time range.

crookesa

Board Regular
Joined
Apr 11, 2013
Messages
88
Hi,

I have a time window for what is considered a night shift, e.g. 0000 - 0559. These times can change wither before or after midnight.
I want to supply a start and end time of a numbers of shifts and see if any part of those shifts falls within the hours above.

I had tried this formula

Code:
=IF(OR(IF(AND(G2>=$A$2,G2<=$B$2),TRUE,FALSE)=TRUE,IF(AND(H2>=$A$2,H2<=$B$2),TRUE,FALSE)=TRUE),TRUE,FALSE)

where A2 & B2 is night shift criteria start & end time and G2 & H2 are the respective start and end times of the shifts I want to check.

I can only get it to work out if a start or end time is within the window but not if any of the duty is included.

Looking for help with the logic thanks...
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
GJ22M8g
Capture.png


Still trying to work on this and taking a new approach but still don't have it quite right
GJ22M8g
.
I thought I could check if the duty start time was between the criteria using the following in E5. The same logic is applied to duty end time. Then the "Any parts?" is either cell TRUE.

Code:
=OR(MOD(A5,1)>$E$2,MOD(A5,1)<$F$2)
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,179
Members
452,615
Latest member
bogeys2birdies

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