Function Problems

How to Count Dates by Year in Excel Using a Formula

Khadija KhanKhadija Khan Nov 4, 2026 870 views

Question details

The user needs to count the number of date entries that fall into specific years within a given dataset.

How to Count Dates by Year in Excel Using a Formula
Product
Microsoft Excel / WPS Spreadsheet
Device & OS
not provided
Scenario
Analyzing a continuous range of dates (such as D2:D100) to find out exactly how many dates occur in specific target years (like 2010, 2011, etc.).
Observed behavior
The goal is to correctly extract the year from the date range and return a total count for each specified year without manually filtering the data.
Before you start

Ensure that your data range contains valid date formats recognized by the spreadsheet program. The formulas will return an error or an incorrect count if the dates are stored as plain text strings.

Solution 1Recommended

Use the SUM and YEAR Array Formula

This method uses the YEAR function to extract the year from a range of dates, compares it to your target year, and uses the SUM function to count the matches.

By combining the SUM and YEAR functions, you can create a powerful array formula. The double negative (--) is used to convert the TRUE and FALSE values returned by the condition into 1s and 0s, which can then be summed up.

1
Set up your target years

In an empty column next to your data, list the years you want to count. For example, enter 2010 in cell J2 and 2011 in cell J3.

2
Enter the SUM formula

Select the cell next to your first target year (e.g., K2) and enter the following formula: =SUM(--(YEAR($D$2:$D$100)=J2)). Make sure to adjust the range $D$2:$D$100 to match your actual date data.

3
Confirm the array formula

If you are using Microsoft 365 or Excel 2021, simply press Enter. If you are using an older version of Excel, you must confirm the formula by pressing Ctrl+Shift+Enter. Curly brackets {} will appear around the formula.

4
Apply to other years

Click on cell K2, hover over the bottom-right corner until you see the fill handle (a plus sign), and drag it down to fill the formula for the remaining years.

Use the SUM and YEAR Array Formula
Absolute References: Using dollar signs ($D$2:$D$100) ensures that your date range remains locked in place when you drag the formula down to other cells.
Advanced Spreadsheet Capabilities

Count Dates and Analyze Data Effortlessly with WPS Office

WPS Spreadsheet offers full support for advanced array formulas, SUMPRODUCT, and dynamic date functions, allowing you to seamlessly analyze, filter, and count data by year without any steep learning curve.

  1. 1. Open your dataset: Launch WPS Spreadsheet and open the workbook containing the dates you need to count.
  2. 2. Input the target years: Create a summary table by typing the years you want to count into a blank column.
  3. 3. Enter the formula: Type =SUMPRODUCT(--(YEAR($D$2:$D$100)=J2)) next to your first year and press Enter. WPS Spreadsheet processes the array natively.
  4. 4. Drag to fill: Click the cell's fill handle and drag it downward to instantly calculate the totals for the remaining years.
Fully compatible with Microsoft Excel formulas, date formats, and array calculations.Easily execute complex data analysis tasks like SUMPRODUCT without additional plugins.Lightweight, incredibly fast, and free to use for daily professional spreadsheet management.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my formula return a #VALUE! error?

This typically occurs if there are text strings or non-date values in your date range (D2:D100) that the YEAR function cannot process. Ensure all cells in your selected range are properly formatted as dates and do not contain text headers.

Can I use COUNTIFS to count dates by year instead of an array formula?

Yes, you can use the COUNTIFS function by specifying a start and end date for the year. For example, to count dates in 2010, you can use: =COUNTIFS(D2:D100, ">=1/1/2010", D2:D100, "<=12/31/2010"). This avoids the need for array processing entirely.

How do I handle blank cells so they aren't counted as the year 1900?

To ignore blank cells in your formula, you can add an additional condition to check for blanks. Modify your formula to: =SUMPRODUCT(--(YEAR($D$2:$D$100)=J2), --($D$2:$D$100<>"")). This ensures empty cells are excluded from your count.