Fix an Excel SUMPRODUCT Formula That Counts Dates by Month
Question details
Count records in a date column that belong to the month and year shown in C34.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A SUMPRODUCT formula compares dates on Sheet1 with the month in C34.
- Observed behavior
- The formula returns zero when it compares dates by month using LEFT and TEXT.
Check that C34 contains a valid Excel date and identify the rows containing dates on Sheet1. Use =ISNUMBER(Sheet1!A2) in an empty cell to check whether a sample date is stored as a number rather than text.
Compare formatted dates with SUMPRODUCT and TEXT
Use this method to count dates that match both the month and year in C34.
Excel stores actual dates as serial numbers. LEFT reads the underlying value rather than reliably extracting the displayed year and month, so convert both sides to the same text format before comparing them.
Click the cell where you want the monthly count to appear.
Enter =SUMPRODUCT(--(TEXT(Sheet1!A2:A1000,"yyyy-mm")=TEXT(C34,"yyyy-mm"))) and press Enter.
Replace Sheet1!A2:A1000 with the bounded range containing your dates. Make sure C34 refers to the cell containing the target date.

Count dates between month boundaries with COUNTIFS
Use this alternative to count dates and date-time values within the target month without converting each date to text.
Count monthly records in WPS Spreadsheets
Open your workbook in WPS Spreadsheets and use COUNTIFS with month boundaries to count dates matching the month and year in C34.
- 1. Open the workbook: Open WPS Spreadsheets and select Open to choose your Excel workbook.
- 2. Check the target date: Select C34 and confirm it contains a valid date in the month you want to count.
- 3. Enter the formula: Select an empty cell and enter =COUNTIFS(Sheet1!A2:A1000,">="&DATE(YEAR(C34),MONTH(C34),1),Sheet1!A2:A1000,"<"&EDATE(DATE(YEAR(C34),MONTH(C34),1),1)). Press Enter.
- 4. Adjust and save: Update both date-range references to match your worksheet, then select Save to keep the result.

Frequently Asked Questions
Why does LEFT return the wrong month from an Excel date?
Excel stores dates as serial numbers, so LEFT operates on the underlying value rather than the displayed date. Use TEXT(A2,"yyyy-mm") to produce a year-and-month string for comparison.
Does the formula distinguish the same month in different years?
Yes. The TEXT formula compares both year and month using the yyyy-mm format. The COUNTIFS alternative also uses boundaries for the specific month and year in C34.
What if my dates are stored as text?
Check a sample cell with =ISNUMBER(A2). If it returns FALSE for a date, convert the text to a valid Excel date before using the formulas; for example, select the affected cells and try Data > Text to Columns with the appropriate date format.
Can I use a whole-column reference in SUMPRODUCT?
It is better to use a bounded range such as Sheet1!A2:A1000. Applying TEXT to an entire column can make the formula slower.




