< Go Back

Count dates in current month

How To Count Dates In Current Month

Counting dates in the current month are crucial especially if you are running a project with a predetermined time frame. However, counting manually can be tiresome and not to mention possible errors. But you can avoid all these hustles by using COUNTIFS OR SUMPRODUCT function. For the COUNTIFS function, here is the formula:

Generic Formula:

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

…where “rng” dates range in the excel sheet. TODAY supplies the current date to the formula while EOMONTH provides actual dates.  Finally, COUNTIF will do the count current month dates.

Example:

Check out how counting dates in the current month have been done in this example:

Figure 1. Example 1 of COUNTIFS Function

In this screenshot, the formula in the highlighted cell (E9) is:

=COUNTIFS(B5:B28,">="&EOMONTH(TODAY(),-1)+1, B5:B28,"<"&EOMONTH(TODAY(),0)+1)

How the Formula Work?

The COUNTIF, which is the core function, count dates in the range and tests whether they meet the requirement i.e., greater than or equal to the first day month of interest (current month) and less than the 1st day of the next month. EOMONTH creates both dates using the current dates which are a return of the TODAY function.

This is the formula that gets the first day of the month:

=EOMONTH(TODAY(),-1)+1

….. the function (EOMONTH) works by returning the previous month’s last day and adding 1 and that gives the first day of the current month.

For the current month’s last date, here is the formula:

EOMONTH(TODAY(),0)+1)

That is how this formula counts dates in the current month. For this example, the count is 4

SUMPRODUCT Alternative

This is another alternative that offers a direct solution. In addition, you can get dates for previous and even next month with it. The formula looks like this:

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

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

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

To solve the problem, a chain of month and year returned by the TEXT function is compared with an array inside SUMPRODUCT. The result is an array of TRUE/FALSE where the TRUE values are dates for a month you are looking for.

The N function is responsible for changing TRUE/FALSE values to 1s and 0s for final tally by SUMPRODUCT.

Our customers love us!
“The expert was absolutely amazing and stuck with me the whole way through. They were polite, patient, seemed to want to genuinely help me and provided a solution that I would never have managed otherwise. I could not be more thankful for their support and solution. Thank you!” - - Chris T, in California
This blog is one way to figure it out. A 20 minute chat session with an expert is a better way.Get step-by-step guidance on your question

Leave a Comment

avatar