That won't work for Dec / Jan
Cell Formulas Range Formula C2:C3 C2 =MONTH(B2)-MONTH(A2)+1
You are correct...it didn't work in the calendar year transition. I used the datedif formula on 01/3022 - 02/20/22 and it still comes back as 1 month. This is with including the +1 in the calculation. Any thoughts?That won't work for Dec / Jan
T202203a.xlsm | |||||||
---|---|---|---|---|---|---|---|
A | B | C | D | E | |||
1 | |||||||
2 | 18-Jan-22 | 18-Feb-22 | 2 | 2 | 2 | ||
3 | 15-Mar-22 | 5-May-22 | 3 | 3 | 3 | ||
4 | 15-Dec-22 | 5-Jan-23 | 2 | 2 | 2 | ||
5 | 5-Mar-21 | 31-May-21 | 3 | 3 | 3 | ||
6 | 30-Jan-22 | 20-Feb-22 | 2 | 2 | 2 | ||
7 | |||||||
2d |
Cell Formulas | ||
---|---|---|
Range | Formula | |
C2:C6 | C2 | =DATEDIF(EOMONTH(A2,-1)+1,EOMONTH(B2,0)+1,"m") |
D2:D6 | D2 | =DATEDIF(A2-DAY(A2)+1,EDATE(B2-DAY(B2)+1,1),"m") |
E2:E6 | E2 | =(YEAR(B2)-YEAR(A2))*12+MONTH(B2)-MONTH(A2)+1 |