Summary

To count dates in the current month, you can use a formula based on the COUNTIFS or SUMPRODUCT function as explained below. In the example shown above, the formula in E7 is:

=COUNTIFS(dates,">="&EOMONTH(TODAY(),-1)+1,dates,"<"&EOMONTH(TODAY(),0)+1)

where "dates" is the named range B5:B104.

Generic formula

=COUNTIFS(rng,">="&EOMONTH(TODAY(),-1)+1,rng,"<"&EOMONTH(TODAY(),0)+1)

Explanation 

At the core, this formula uses the COUNTIFS function to count dates that are greater than or equal to the first day of the current month, and less than the first day of the next month. The EOMONTH function is used to create both dates based on the current date, which is supplied by the TODAY function.

=COUNTIFS(dates,">="&EOMONTH(TODAY(),-1)+1,dates,"<"&EOMONTH(TODAY(),0)+1)

To get the first day of the month, we use the EOMONTH function like this:

EOMONTH(TODAY(),-1)+1

EOMONTH returns the last day of the previous month, to which 1 is added to get the first day of the current month. In a similar way, we use EOMONTH to get the first day of the next month:

EOMONTH(TODAY(),0)+1

EOMONTH returns the last day of the current month, to which 1 is added to get the first day of the next month. The literal translation of the logic in COUNTIFS is: greater than or equal to the first day in the current month AND less than the first day of the next month.

Alternatively, you could use less than or equal (<=) operator for the last day like this:

=COUNTIFS(dates,">="&EOMONTH(TODAY(),-1)+1,dates,"<="&EOMONTH(TODAY(),0))

Previous and next months

To count dates in the previous month:

=COUNTIFS(dates,">="&EOMONTH(TODAY(),-2)+1,dates,"<"&EOMONTH(TODAY(),-1)+1) 

To count dates in the next month:

=COUNTIFS(dates,">="&EOMONTH(TODAY(),0)+1,dates,"<"&EOMONTH(TODAY(),1)+1)

SUMPRODUCT alternative

You can also count dates in the previous, current, and next month using SUMPRODUCT function together with the TEXT function like this:

=SUMPRODUCT(N(TEXT(EOMONTH(TODAY(),-1),"mmyy")=TEXT(rng,"mmyy")))
=SUMPRODUCT(N(TEXT(TODAY(),"mmyy")=TEXT(rng,"mmyy")))
=SUMPRODUCT(N(TEXT(EOMONTH(TODAY(),1),"mmyy")=TEXT(rng,"mmyy")))

Here, dates are fed into the TEXT function to get a month and year string, which is used for comparison in an array operation inside SUMPRODUCT. The result is an array of TRUE FALSE values, where TRUE represents dates in the month of interest.

The N function is used to change these values to ones and zeros, and SUMPRODUCT simply sums and returns the array.

Dave Bruns Profile Picture

AuthorMicrosoft Most Valuable Professional Award

Dave Bruns

Hi - I'm Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.