Count Times Between Two Values in Excel with COUNTIFS or SUMPRODUCT
Question details
Count alarm occurrences in a single Excel column between two specified times without a formula parse error.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Alarm times are stored in column D on the September worksheet, and the user wants to count entries between times such as 6:00 a.m. and 12:00 p.m.
- Observed behavior
- A formula parse error prevents the user from calculating the count.
Enter the start time in D1 and the end time in E1 on the worksheet where you will enter the formula. Confirm that September!D2:D1500 contains real time values rather than text and that the start time is earlier than the end time.
Count the time range with COUNTIFS
Use COUNTIFS to apply both time boundaries to the same column.
In the worksheet where you want the result, enter 6:00 AM in D1 and 12:00 PM in E1, or use your own start and end times.
Select an empty result cell and enter =COUNTIFS(September!D2:D1500,">"&D1,September!D2:D1500,"<"&E1). Press Enter.
Compare the result with the times in September!D2:D1500. Adjust the range in both parts of the formula if your data extends beyond row 1500.

Count the time range with SUMPRODUCT
Use SUMPRODUCT as an alternative when you prefer to multiply two comparison tests.
Count alarm times in WPS Spreadsheets
Open your workbook in WPS Spreadsheets and use COUNTIFS to count time values between two cell-based boundaries.
- 1. Open the workbook: Open WPS Spreadsheets and use Open to select your Excel workbook.
- 2. Enter the boundaries: On the worksheet for your result, enter the start time in D1 and the end time in E1.
- 3. Count the times: Select an empty cell and enter =COUNTIFS(September!D2:D1500,">"&D1,September!D2:D1500,"<"&E1), then press Enter.
- 4. Save the workbook: Use File > Save As to save the updated workbook in XLSX format if needed.

Frequently Asked Questions
How do I include alarms exactly at the start and end times?
In the COUNTIFS formula, replace ">" with ">=" and "<" with "<=". This includes values equal to D1 or E1.
Why does Excel report a formula parse error?
Check that comparison operators are enclosed in quotes and joined to cell references with &, as in ">"&D1. If your Excel regional settings use semicolons as argument separators, replace the commas between COUNTIFS arguments with semicolons.
Why are visible times not being counted?
Check whether the source cells contain actual time values rather than text. Also check whether they contain dates as well as times: these formulas compare the full stored value, not just the displayed time.
Can these formulas count a range that crosses midnight?
Not as written. They require the start time in D1 to be earlier than the end time in E1. A range such as 10:00 PM to 6:00 AM needs separate tests for times after the start or before the end.




