Formula Errors

Check Shift Start Times Between 10 PM and 8 AM in Excel

Chanuka GeekiyanageChanuka Geekiyanage Dec 2, 2026 868 views

Question details

Check whether a shift start time falls in an overnight range and display Yes or No.

Check Shift Start Times Between 10 PM and 8 AM in Excel
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.
Before you start

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.

Solution 1Recommended

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.

1
Enter the formula

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.

2
Fill the formula down

Select E2 and drag its fill handle down alongside the remaining shift start times.

Use an IF and OR formula for the overnight range
Include exactly 8:00 AM if needed: The formula includes 10:00 PM but excludes exactly 8:00 AM. To include 8:00 AM, change D2<TIME(8,0,0) to D2<=TIME(8,0,0).
WPS Spreadsheet

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. 1. Open the spreadsheet: In WPS Spreadsheet, open the workbook containing your shift start times.
  2. 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. 3. Apply it to other shifts: Select E2 and drag the fill handle down to copy the formula to the other rows.
Check shift times across midnight with a familiar formulaOpen and edit Microsoft Excel XLSX and XLS filesFill formulas down across multiple shift rowsWork in a familiar spreadsheet interface
microsoft office alternative - wps office

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")).