Count dates in a given year

By combining the SUMPRODUCT and YEAR functions in Excel we can find the number of Dates in a given Year.


Here we have a list of dates in the cells from B3:B15. The following formula will return the number of dates in the year 2020.



SUMPRODUCT functions multiplies the arrays specified in it and returns the ‘sum of products’ as result. If a single array is used inside it, SUMPRODUCT function will return the sum of values in that array.

YEAR function extracts the year from a valid Excel date. Here, when the range B3:B15 is used inside YEAR function, the expression evaluates to an array of years like the following.


Then each of these values will be compared with the value 2020 and produce an array of TRUE and FALSE values.


These TRUE and FALSE values are then coerced into 1 (Ones) and 0 (Zeros) using ‘ – –‘ double negative (also called double unary). The resulting array will be like,


Finally, SUMPRODUCT function will return the sum of values in the array, which is 3 in this case.

Formula with cell reference

In the above example we were using the direct value ‘2020’. Instead of hard coding the value in the formula, we can use the address of the cell that contains the Year to search for.

The following formula returns the number of cells containing the date of the Year present in cell D6.


Here, the cell D6 contains the year ‘2019‘. So the formula returned the value 2.

Excel Formulas

Excel Functions