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

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
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,224,818
Messages
6,181,152
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