## Tuesday, July 16, 2013

### Google Spreadsheets - Count number of Dates before today of previous years

Question:

( by Matt )

I shared a sample sheet below.
In F2, I'd like a formula that counts how many Events (column A) were Booked (column B) today's date or before, of that year.
So for 2008, there were 52 events, I'd like to know how many were booked on or before 7/15/2008 (today's day and month, of that year.)
The expected answer for 2008 is 46

Sample Sheet:

Thank you,
Matt O.

Solution:

Have a look at the following sheet:

I have the following formula in Cell E2:
=count(iferror(filter(\$A:\$A;year(\$A:\$A)=D2)))

Now you can drag the above formula to Cell E3, E4 and so on...

I have the following formula in Cell F2:
=count(iferror(filter(\$B:\$B;year(\$B:\$B)=D2;\$B:\$B<=date(D2;month(\$C\$2);day(\$C\$2)))))

Updated formula:
=count(iferror(filter(\$B:\$B;year(\$A:\$A)=D2;\$B:\$B<=date(D2;month(\$C\$2);day(\$C\$2)))))

Now you can drag the above formula to Cell F3, F4 and so on...

in the above formula, you can replace \$C\$2 with today()

I hope the above solution will help you, and if you need more help then please do comment below on this blog itself, I will try to help you out.

I also take up private and confidential projects:
If this blog post was helpful to you, and if you think you want to help me too and make my this blog survive then please donate here: http://igoogledrive.blogspot.com/2012/09/donate.html

Thanks,

1. The formula needs to take into account column A for the event date.
Please see the highlighted cells near the bottom of the 1st column for an example.
If the event is in 2013, it HAD to have been booked before today's date. The expected answer for 2013 is 94
Thank you!

1. Hi Matt,

In this case you need to update the Formula in Cell F2 as:
=count(iferror(filter(\$B:\$B;year(\$A:\$A)=D2;\$B:\$B<=date(D2;month(\$C\$2);day(\$C\$2)))))

And drag it to cells below.

I hope this helps.

2. Perfect, thank you