How to Count Dates of Given Year in Excel

This post will guide you how to count Dates of a certain year in the range of dates using a formula in Excel 2013/2016 or Excel office 365. How do I count dates by a given year in Excel. And you may be want to count the cells where dates are from a particular year. It should be similar with the previous post that how to count dates by day of week. And we can use the SUMPRODUCT function and the YEAR function to build a formula to count the date values where the date belongs the specific given year.

Count Dates of Given Year Through Formula


Assuming that you may be want to count dates of given year in date range B1:B6. You can use the below formula based on the SUMPRODUCT function and the YEAR function, like this:

=SUMPRODUCT(–(YEAR($B$1:$B$6)=D2))

count dates of given year1

Note: you need to change date range as you need. And changing year value given as cell reference.

LETS SEE THAT HOW THIS FORMULA WORKS

=YEAR(B1:B6)

count dates of given year2

The YEAR function will extract the year value from the given data range. And it returns an array result like this:

{2021;2020;2021;2021;2018;2020}

count dates of given year3

=YEAR(B1:B6)=D2

count dates of given year4

Then the array results returned by YEAR formula are compared to the given year value, and returns another array result of TRUE and FALSE values like this:

{FALSE;TRUE;FALSE;FALSE;FALSE;TRUE}

count dates of given year5

=–(YEAR(B1:B6)=D2)

count dates of given year6

You still need to convert the TRUE or FALSE values to 1 and 0 values using the double negative operator. And returns the below array result:

{1;0;0;0;0;0}

count dates of given year7

The SUMPRODUCT function just sums all values of an array returned by the above formula.

You can see that the total date matches of the year 2020 comes out to be 2. And it means that there are 2 date values where the year value equals to 2020.

Related Functions


  • Excel SUMPRODUCT function
    The Excel SUMPRODUCT function multiplies corresponding components in the given one or more arrays or ranges, and returns the sum of those products. The syntax of the SUMPRODUCT function is as below:= SUMPRODUCT (array1,[array2],…)…
  • Excel YEAR function
    The Excel YEAR function returns a four-digit year from a given date value, the year is returned as an integer ranging from 1900 to 9999. The syntax of the YEAR function is as below:=YEAR (serial_number)…
Related Posts

Add Months To Date In Excel

It is important to adjust time periods when performing financial modeling. In Excel, you can use the MONTH function to add a specific number of months to a date. The MONTH function takes one argument: the number of months you ...

Add Days to Date in MS Excel

If you are an vavid MS Excel user, then you might have come across situations where you need to add the same or different days into the particular date, and if you have done this task manually, then let me ...

Filter Data By Date Field

The use of Microsoft Excel's Format Cells and Auto Filter option is a great way to filter data by year or Month. This article will discuss how to filter by date field using Filter function and Format cells in Microsoft ...

How to Count Occurrences in Entire Workbook in Excel

This post will guide you how to count number of occurrences in whole workbook in Excel 2013/2016 or Excel office 365. How do I count how many times a string is repeated in all worksheets in Excel. You may be ...

How to Sum Values Based on Month and Year in Excel

We often do some summary or statistic at the end of one month or one year. In these summary tables, there are at least two columns, one column records the date, and the other column records the sales or product ...

Sidebar