## Summary

To count times that occur within a certain range, you can use the COUNTIFs function. In the example shown, the formula in E7 is:

``````=COUNTIFS(B5:B11,">="&E5,B5:B11,"<"&E6)
``````

## Generic formula

``=COUNTIFS(rng,">="&start,rng,"<"&end)``

## Explanation

The COUNTIFS function takes one or more criteria, entered as range/criteria pairs. In this example, the first range/criteria pair is:

``````B5:B11,">="&E5
``````

Matching any time greater than or equal to the time E5 (5:00).

The second range/criteria pair is:

``````B5:B11,"<"&E6
``````

Matching any time less than the time in E6 (6:30).

### With hard-coded values

The formula in E7 could be written with hard-coded time values as follows:

``````=COUNTIFS(B5:B11,">=5:00",B5:B11,"<6:30")
``````

Excel translates a string like "5:00" into the correct numeric time value.

### With the TIME function

The formula in E7 could be written with the TIME function like this:

``````=COUNTIFS(B5:B11,">="&TIME(5,0,0),B5:B11,"<"&TIME(6,30,0))
``````

The TIME function provides a simple way to assemble a valid time using discreet hour, minute, and second values. Author ### Dave Bruns

Hi - I'm Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.