Count Excel Dates by Month Without Hard-Coding the Year
Question details
Count dates in a selected month while allowing the year to change without editing the counting formula.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A worksheet contains dates to count by month, and the user wants to switch years automatically or through a cell.
- Observed behavior
- The count should reflect the selected month and year, updating when either input changes.
Identify the cells containing your dates and confirm they are stored as actual spreadsheet dates rather than text. The examples below use A2:A100 for dates, E1 for the year, and F1 for a month number from 1 to 12.
Count a Selected Month Using COUNTIFS and Date Boundaries
Use this formula to change the month or year through worksheet cells instead of rewriting the count.
In E1, enter =YEAR(TODAY()) to use the current year automatically. Alternatively, enter a year such as 2023 to select it manually.
In F1, enter a month number from 1 to 12; for example, enter 1 for January.
Select an empty cell and enter =COUNTIFS(A2:A100,">="&DATE(E1,F1,1),A2:A100,"<"&EDATE(DATE(E1,F1,1),1)). Adjust A2:A100 if your dates are in a different range.
Change F1 to count another month, or change E1 if you entered the year manually. If E1 contains =YEAR(TODAY()), the formula uses the current year.

Count Dates by Month in WPS Spreadsheets
Use COUNTIFS with DATE and EDATE in WPS Spreadsheets to count a selected month and update the year automatically.
- 1. Open your workbook: Open WPS Spreadsheets and select Open to load the workbook containing your dates.
- 2. Enter the year and month: Enter =YEAR(TODAY()) in E1 and a month number from 1 to 12 in F1.
- 3. Add the formula: In an empty cell, enter =COUNTIFS(A2:A100,">="&DATE(E1,F1,1),A2:A100,"<"&EDATE(DATE(E1,F1,1),1)). Replace A2:A100 with your date range if needed.
- 4. Review the count: Change the month number in F1 to count another month, then use File > Save to save your workbook.

Frequently Asked Questions
How can I count a month in a different year?
Enter the desired year in E1 and the month number in F1. The COUNTIFS formula will use those cells to set its date boundaries.
How do I count the same month last year?
Enter =YEAR(TODAY())-1 in E1 and the desired month number in F1. The count will use the previous calendar year.
Will the formula count dates that include times?
Yes. The formula uses a boundary before the first day of the next month, so dates with times on the last day of the selected month are included.
Why does the formula return zero when dates are visible?
Check that the values in A2:A100 are actual spreadsheet dates rather than text, and confirm that E1 contains the intended year and F1 contains a number from 1 to 12.




