1
votes

I have one row filled with dates in the format MM/dd/yyyy (with header row), such as:

DATES
5/12/2015
4/12/2012
5/7/2015
5/7/2014

I would like to count the number of rows which match the current month & year. In the example above, the result would obviously be two (when it's May 2015).

Is this possible to achieve this result using a function? Preferably using Google Spreadsheet, but Excel is also fine.

3
Yes it is possible, but I would prefer a macro.moffeltje

3 Answers

2
votes

With data in A1 through A20

=SUMPRODUCT((MONTH(A1:A20)=MONTH(TODAY()))*(YEAR(A1:A20)=YEAR(TODAY())))

enter image description here

2
votes

You can use COUNTIFS like this

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

That works equally well in Excel or google sheets, for the whole column and will ignore the header row

1
votes

In Google sheets you can use

=COUNT(FILTER(A:A,MONTH(A:A) = MONTH(TODAY()),YEAR(A:A)=YEAR(TODAY())))

Where A:A is the column with your dates