Forum Discussion
CollinRosser
Dec 07, 2021Copper Contributor
Counting the number of each month between two dates?
Howdy, I am attempting to build a calculator that quantifies weather days in a time period by first quantifying the number of each month (EX: January: 3, Feburary: 3, March: 2, etc...) between tw...
tauqeeracma
Dec 11, 2021Iron Contributor
Hi CollinRosser
You can use the below formula to quantify how many times a month comes in a given date range.
=IF(YEAR($G$14)<YEAR($I$16),IF(VLOOKUP(F18,$F$34:$G$45,2,0)<VLOOKUP((TEXT($G$14,"MMMM")),$F$34:$G$45,2,0),0,1),IF(AND(VLOOKUP(F18,$F$34:$G$45,2,0)>=VLOOKUP((TEXT($G$14,"MMMM")),$F$34:$G$45,2,0),VLOOKUP(F18,$F$34:$G$45,2,0)<=VLOOKUP((TEXT($I$16,"MMMM")),$F$34:$G$45,2,0)),1,0))+IF(((YEAR($I$16))-(YEAR($G$14))-1)<0,0,((YEAR($I$16))-(YEAR($G$14))-1))+IF(YEAR($I$16)>YEAR($G$14),IF(VLOOKUP(F18,$F$34:$G$45,2,0)>VLOOKUP((TEXT($I$16,"MMMM")),$F$34:$G$45,2,0),0,1),0)
You may also refer to the attached file wherein I have also copied this formula in your Date Calculator.
I have also included a 'Working' sheet in the same file that may help you understand the logic.
Please let me know if it works for you.
Thanks
Tauqeer