Validating times that span midnight

Galley

Board Regular
Joined
Nov 8, 2012
Messages
64
I am working on a spreadsheet to track machine downtime. The user enters the start time and end time of any machine downtime. The time entered must occur on or after the lot start time or shift start time (whichever occurs first) and on or before the lot end time or shift end time, (whichever occurs first):

1st shift starts at 07:00
2nd shift starts at 15:00
3rd shift starts at 23:00</SPAN>

A1 = lot start</SPAN>
A2 = lot end</SPAN>
B1 = downtime start</SPAN>
C1 = downtime end</SPAN>

Validating the downtime (Time between A1 and A2) works fine as long as that time does not span midnight. </SPAN>
Likewise,
Code:
=IF(B1>=A1, B1<=A2)
validates as a TRUE statement as long as the time does not span midnight.</SPAN>
I don’t have any issue with calculating the length of the downtime; I just need to write a custom validation formula that will only accept values within the range. Is there any way to do it without involving dates? </SPAN>
Thanks</SPAN>
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
That works. Thank you very much!

I was aready using the following formula to calculate the length of the downtime. It will work with times that span midnight, so I knew the solution had to be similar.
Code:
(B1>C1)+(C1-B1)
 
Upvote 0

Forum statistics

Threads
1,215,343
Messages
6,124,405
Members
449,157
Latest member
mytux

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