Formula Errors

Fix an Excel SUMPRODUCT Formula That Counts Dates by Month

Algirdas JasaitisAlgirdas Jasaitis Nov 18, 2026 869 views

Question details

Count records in a date column that belong to the month and year shown in C34.

Fix an Excel SUMPRODUCT Formula That Counts Dates by Month
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.
Before you start

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.

Solution 1Recommended

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.

1
Select the result cell

Click the cell where you want the monthly count to appear.

2
Enter the formula

Enter =SUMPRODUCT(--(TEXT(Sheet1!A2:A1000,"yyyy-mm")=TEXT(C34,"yyyy-mm"))) and press Enter.

3
Adjust the range

Replace Sheet1!A2:A1000 with the bounded range containing your dates. Make sure C34 refers to the cell containing the target date.

Compare formatted dates with SUMPRODUCT and TEXT
Check the date values: The formula expects actual date values in C34 and the date range. Convert dates stored as text to valid dates before counting them.
Count dates by month

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. 1. Open the workbook: Open WPS Spreadsheets and select Open to choose your Excel workbook.
  2. 2. Check the target date: Select C34 and confirm it contains a valid date in the month you want to count.
  3. 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. 4. Adjust and save: Update both date-range references to match your worksheet, then select Save to keep the result.
Count dates and date-time values within a selected monthOpen and edit Microsoft Excel XLSX and XLS filesUse a familiar spreadsheet interface and formulas
microsoft office alternative - wps office

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.