Function Problems

Check Whether an Excel Time Is Between 20:00 and 22:00

Tauseeq MagsiTauseeq Magsi Dec 2, 2026 868 views

Question details

Determine whether an Excel time falls between 20:00:00 and 22:00:00, including both endpoints.

Check Whether an Excel Time Is Between 20:00 and 22:00
Product
Microsoft Excel
Device & OS
not provided
Scenario
A user wants a formula that checks a time in a worksheet cell against an evening time range.
Observed behavior
The formula should return TRUE for times from 20:00:00 through 22:00:00 and FALSE for times outside that range.
Before you start

Check that C2 contains a numeric Excel time or date-time value rather than text. If your time is in another cell, replace C2 in the formula with that cell reference.

Solution 1

Use AND to check the inclusive time range

Use this formula for a time or date-time in C2; it checks only the time portion.

1
Select a result cell

Click an empty cell, such as D2, next to the time in C2.

2
Enter the formula

Enter =AND(MOD(C2,1)>=TIME(20,0,0),MOD(C2,1)<=TIME(22,0,0)) in D2 and press Enter.

3
Apply it to other rows

Drag the fill handle from D2 down to check the corresponding times in column C.

Boundary times are included: The formula returns TRUE for exactly 20:00:00 and 22:00:00. MOD(C2,1) removes any date portion before the comparison.
Check time ranges in WPS Spreadsheet

Check an inclusive time range in WPS Spreadsheet

Use the same AND, MOD, and TIME formula in WPS Spreadsheet to check whether a time falls between 20:00 and 22:00.

  1. 1. Open your workbook: Open WPS Spreadsheet and select your workbook, or create a new spreadsheet.
  2. 2. Enter a time: Enter a time or date-time value in cell C2.
  3. 3. Add the formula: Select D2, enter =AND(MOD(C2,1)>=TIME(20,0,0),MOD(C2,1)<=TIME(22,0,0)), and press Enter.
  4. 4. Check more rows: Drag the fill handle from D2 down to apply the formula to other entries in column C.
Check both boundary times with an inclusive formulaWork with Microsoft Excel XLS and XLSX filesUse familiar spreadsheet functions and a familiar interfaceCopy the formula down a column to check multiple rows
microsoft office alternative - wps office

Frequently Asked Questions

Does the formula include 20:00 and 22:00?

Yes. The >= and <= operators include both endpoints, so exactly 20:00:00 and 22:00:00 return TRUE.

Will the formula work if C2 contains a date as well as a time?

Yes. In =AND(MOD(C2,1)>=TIME(20,0,0),MOD(C2,1)<=TIME(22,0,0)), MOD(C2,1) extracts the time portion of a numeric date-time value.

Why does my time formula return an error for a text value?

The formula expects a numeric time. If C2 contains recognizable time text, enter =TIMEVALUE(C2) in a helper cell and use that cell in the comparison.

Can I use HOUR instead of comparing full times?

A formula such as =OR(HOUR(C2)=20,HOUR(C2)=21) checks the hour, but it excludes exactly 22:00:00. Use the AND formula when both exact boundaries must be included.