Check Shift Start Times Between 10 PM and 8 AM in Excel
Question details
Check whether a shift start time falls in an overnight range and display Yes or No.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Shift start times need to be compared with a range that crosses midnight, from 10:00 PM to 8:00 AM.
- Observed behavior
- The desired result is Yes for a start time within the overnight range and No otherwise.
Make sure the shift start cells contain valid Excel time values, not text, and identify the first cell to check. The formula below assumes D2 contains a time without a date.
Use an IF and OR formula for the overnight range
Return Yes for times from 10:00 PM up to, but not including, 8:00 AM.
OR checks both sides of midnight: times at or after 10:00 PM and times before 8:00 AM.
In E2, or another result cell on row 2, enter =IF(OR(D2<TIME(8,0,0),D2>=TIME(22,0,0)),"Yes","No"). Replace D2 if the shift start time is in a different cell.
Select E2 and drag its fill handle down alongside the remaining shift start times.

Check overnight shift times in WPS Spreadsheet
Use the same IF and OR formula in WPS Spreadsheet to label overnight shift start times Yes or No.
- 1. Open the spreadsheet: In WPS Spreadsheet, open the workbook containing your shift start times.
- 2. Enter the formula: Select E2 and enter =IF(OR(D2<TIME(8,0,0),D2>=TIME(22,0,0)),"Yes","No"), adjusting D2 to match your start-time cell.
- 3. Apply it to other shifts: Select E2 and drag the fill handle down to copy the formula to the other rows.

Frequently Asked Questions
Does the formula include 10:00 PM and 8:00 AM?
It includes exactly 10:00 PM because it uses >=TIME(22,0,0), but excludes exactly 8:00 AM because it uses <TIME(8,0,0). Change < to <= if 8:00 AM should be included.
What if the start cell contains both a date and a time?
Use MOD to isolate the time portion: =IF(OR(MOD(D2,1)<TIME(8,0,0),MOD(D2,1)>=TIME(22,0,0)),"Yes","No"). This still excludes exactly 8:00 AM.
Can I return TRUE or FALSE instead of Yes or No?
Yes. Enter =OR(D2<TIME(8,0,0),D2>=TIME(22,0,0)) in the result cell and fill it down.
Why does a blank start-time cell return Yes?
A blank cell can be treated as zero, equivalent to midnight. To leave the result blank, use =IF(D2="","",IF(OR(D2<TIME(8,0,0),D2>=TIME(22,0,0)),"Yes","No")).




