Dealing with Date Ranges and Countifs function
I have a metric sheet that I am trying to pull data from another sheet.
I am trying to get counts by person that fall:
within 3 months
within 3-6 months
within 6-9 months
within 9-12 months
within 12 months.
I have done a few searches within the community, but I cannot wrap my head around this. Any thoughts?
Best Answers
-
Give these a go…
within 3 months:
=COUNTIFS({Date Range}, AND(@cell >= TODAY(), @cell <= IFERROR(DATE(YEAR(TODAY()), MONTH(TODAY()) + 3, DAY(TODAY())), DATE(YEAR(TODAY()) + 1, MONTH(TODAY()) - 9, DAY(TODAY())))))
within 3-6 months:
=COUNTIFS({Date Range}, AND(@cell > IFERROR(DATE(YEAR(TODAY()), MONTH(TODAY()) + 3, DAY(TODAY())), DATE(YEAR(TODAY()) + 1, MONTH(TODAY()) - 9, DAY(TODAY()))), @cell <= IFERROR(DATE(YEAR(TODAY()), MONTH(TODAY()) + 6, DAY(TODAY())), DATE(YEAR(TODAY()) + 1, MONTH(TODAY()) - 6, DAY(TODAY())))))
within 6-9 months:
=COUNTIFS({Date Range}, AND(@cell > IFERROR(DATE(YEAR(TODAY()), MONTH(TODAY()) + 6, DAY(TODAY())), DATE(YEAR(TODAY()) + 1, MONTH(TODAY()) - 6, DAY(TODAY()))), @cell <= IFERROR(DATE(YEAR(TODAY()), MONTH(TODAY()) + 9, DAY(TODAY())), DATE(YEAR(TODAY()) + 1, MONTH(TODAY()) - 3, DAY(TODAY())))))
within 9-12 months:
=COUNTIFS({Date Range}, AND(@cell > IFERROR(DATE(YEAR(TODAY()), MONTH(TODAY()) + 9, DAY(TODAY())), DATE(YEAR(TODAY()) + 1, MONTH(TODAY()) - 3, DAY(TODAY()))), @cell <= DATE(YEAR(TODAY()) + 1, MONT(TODAY()), DAY(TODAY()))
within 12 months:
=COUNTIFS({Date Range}, AND(@cell >= TODAY(), @cell <= DATE(YEAR(TODAY()) + 1, MONTH(TODAY()), DAY(TODAY()))))
-
Happy to help. 👍️
Sorry about missing that H. It happened quite a few times when typing those out, but I seem to have missed that one. I think it may be time for a new keyboard. Haha.
Answers
-
Am I correct in assuming that you mean within # months of today's date?
-
Paul, yeah, # of months from today's date.
-
Give these a go…
within 3 months:
=COUNTIFS({Date Range}, AND(@cell >= TODAY(), @cell <= IFERROR(DATE(YEAR(TODAY()), MONTH(TODAY()) + 3, DAY(TODAY())), DATE(YEAR(TODAY()) + 1, MONTH(TODAY()) - 9, DAY(TODAY())))))
within 3-6 months:
=COUNTIFS({Date Range}, AND(@cell > IFERROR(DATE(YEAR(TODAY()), MONTH(TODAY()) + 3, DAY(TODAY())), DATE(YEAR(TODAY()) + 1, MONTH(TODAY()) - 9, DAY(TODAY()))), @cell <= IFERROR(DATE(YEAR(TODAY()), MONTH(TODAY()) + 6, DAY(TODAY())), DATE(YEAR(TODAY()) + 1, MONTH(TODAY()) - 6, DAY(TODAY())))))
within 6-9 months:
=COUNTIFS({Date Range}, AND(@cell > IFERROR(DATE(YEAR(TODAY()), MONTH(TODAY()) + 6, DAY(TODAY())), DATE(YEAR(TODAY()) + 1, MONTH(TODAY()) - 6, DAY(TODAY()))), @cell <= IFERROR(DATE(YEAR(TODAY()), MONTH(TODAY()) + 9, DAY(TODAY())), DATE(YEAR(TODAY()) + 1, MONTH(TODAY()) - 3, DAY(TODAY())))))
within 9-12 months:
=COUNTIFS({Date Range}, AND(@cell > IFERROR(DATE(YEAR(TODAY()), MONTH(TODAY()) + 9, DAY(TODAY())), DATE(YEAR(TODAY()) + 1, MONTH(TODAY()) - 3, DAY(TODAY()))), @cell <= DATE(YEAR(TODAY()) + 1, MONT(TODAY()), DAY(TODAY()))
within 12 months:
=COUNTIFS({Date Range}, AND(@cell >= TODAY(), @cell <= DATE(YEAR(TODAY()) + 1, MONTH(TODAY()), DAY(TODAY()))))
-
THANK YOU!!! THANK YOU!!! THANK YOU!!!
These worked like a charm. Note to anyone else who uses this - the 9-12 section is missing an "H" in Month!
-
Happy to help. 👍️
Sorry about missing that H. It happened quite a few times when typing those out, but I seem to have missed that one. I think it may be time for a new keyboard. Haha.
Help Article Resources
Categories
- All Categories
- 14 Welcome to the Community
- Smartsheet Customer Resources
- 64.3K Get Help
- 419 Global Discussions
- 221 Industry Talk
- 461 Announcements
- 4.8K Ideas & Feature Requests
- 143 Brandfolder
- 142 Just for fun
- 58 Community Job Board
- 462 Show & Tell
- 32 Member Spotlight
- 1 SmartStories
- 300 Events
- 39 Webinars
- 7.3K Forum Archives
Check out the Formula Handbook template!