Forum Discussion
qdanazumi
Aug 11, 2022Copper Contributor
calculating months between two dates with rounding
I have been trying to look for the number between these two months while rounding to the next month if the day passes the 15th
- Aug 11, 2022
With dates in A3 and B3:
=(12*YEAR(B3)+MONTH(B3)+(DAY(B3)>15))-(12*YEAR(A3)+MONTH(A3)+(DAY(A3)>15))
qdanazumi
Aug 11, 2022Copper Contributor
I tried this formula and unfortunately, it didn't work. The formula hans gave seems to work
HansVogelaar
Aug 11, 2022MVP
Hi Niko,
Your formula doesn't work correctly if the dates are more than a year apart, nor if the month number of the first date is larger than the month number of the second date:
- NikolinoDEAug 11, 2022Platinum ContributorThat's right, you're absolutely right...strange...I have to find out why this is happening.
Qdanazumi: Please use Mr. Hans Vogelaar's formula and ignore mine.
sry for the circumstances.- HansVogelaarAug 11, 2022MVP
It's because you subtract two month numbers without taking the year into account, so the result will vary from 1-12 = -11 to 12-1 = 11.
- qdanazumiAug 11, 2022Copper Contributorthank you