How to Count Excel Records for a Specific Month and Year
Question details
The user needs to count the number of records in an Excel dataset that match a specific text criterion and fall within a given month and year.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Analyzing data where records need to be counted based on multiple conditions, specifically isolating entries from a certain month and year alongside another text condition.
- Observed behavior
- The goal is to accurately calculate the count without errors caused by time values attached to the dates or invalid date formats.
Ensure that the column containing your dates is formatted as valid Excel dates, not as text strings, so the formulas can correctly interpret the month and year.
Use the COUNTIFS Function with Date Ranges
The most reliable method to count records for a specific month and year is by defining a date range with the COUNTIFS function.
By setting a 'greater than or equal to' start date and a strictly 'less than' end date for the following month, COUNTIFS accurately captures all dates within the target month. This method is exceptionally reliable because it prevents errors that occur when cells contain time values in addition to dates.
Click on an empty cell where you want the final count result to be displayed.
Type the formula =COUNTIFS(C2:C434,">="&DATE(2021,1,1),C2:C434,"<"&DATE(2021,2,1),A2:A434,"BB"). Replace the ranges with your actual data ranges.
Press the Enter key. Excel will return the total number of records that match your text condition and fall within January 2021.

Count Records Using the SUMPRODUCT Function
You can also extract the month and year directly within the formula using SUMPRODUCT, which is useful when you want to avoid setting specific start and end dates.
Master Complex Formulas with WPS Spreadsheet
WPS Spreadsheet offers a powerful and highly compatible environment for executing complex functions like COUNTIFS and SUMPRODUCT. Analyze your data effortlessly with its intuitive interface and advanced calculation capabilities.
- 1. Install the software: Download and install WPS Office Free on your computer or mobile device.
- 2. Open your dataset: Launch WPS Spreadsheet and open your existing Excel workbook containing the records.
- 3. Apply your formula: Select the target cell, paste your COUNTIFS or SUMPRODUCT formula, and let WPS instantly calculate your specific date and text criteria.

Frequently Asked Questions
Why is my COUNTIFS formula returning zero when counting by date?
This usually happens if the dates in your dataset are stored as text rather than valid Excel date values. You can fix this by selecting the date column, navigating to the Data tab, and using the "Text to Columns" feature to quickly convert them to recognized dates.
Can I use cell references for the month and year instead of hardcoding them?
Yes. In both COUNTIFS and SUMPRODUCT, you can replace the hardcoded numbers (like 2021 or 1) with a cell reference (e.g., E1 for the year and E2 for the month) to make your reporting dashboard dynamic.
How do I handle cells that contain both date and time in these formulas?
The YEAR and MONTH functions within SUMPRODUCT automatically extract the correct year and month from a date-time serial number, ignoring the time. If using COUNTIFS, the safest approach is to set the end condition as strictly less than the first day of the following month (e.g., "<"&DATE(2021,2,1)), ensuring any times on the last day of the target month are fully captured.




