Calculate # of months between two dates

megera716

Board Regular
Joined
Jan 3, 2013
Messages
146
Office Version
  1. 365
Platform
  1. Windows
I know this is such an easy one, but I'm not getting the desired result and there's a lot of complicated formulas out there that are throwing me off!

I just want to calculate the difference between month numbers. So April (4) and October (10) is 6. September (9) and October (10) is 1. December (12) and January (1) is also 1 but my formula:
=MONTH(AC1063)-MONTH(AP1063) returned -11.

I don't care what the day of the date is -- even if it's 12/29/19 and 1/2/2020, I want it to return 1.
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
I was using that first but it doesn't work if it's not a full month.
 
Upvote 0
The formula is longer, but it works for dates with a difference of more than 11 months.


=DATEDIF(DATE(YEAR(AP1063),MONTH(AP1063),1),DATE(YEAR(AC1063),MONTH(AC1063),1),"m")


For example:

12/29/2019 and 12/2/2020
=MOD(MONTH(AC1063)-MONTH(AP1063),12)
Return 0


12/29/2019 and 12/2/2020
=DATEDIF(DATE(YEAR(AP1063),MONTH(AP1063),1),DATE(YEAR(AC1063),MONTH(AC1063),1),"m")
Return 12
 
Upvote 0
If the OP needs to cover multi-year spans, there is a shorter formula, with fewer function calls and reference calls:

=DATEDIF(EOMONTH(AP1063,-1)+1,EOMONTH(AC1063,-1)+1,"m")
 
Upvote 0
Good option to find the first day of the month, I missed a little, but works.

From the first example the OP set dates for different years. And it is not multi-year, 12 months is still a single year. ;)
 
Upvote 0

Forum statistics

Threads
1,223,705
Messages
6,173,996
Members
452,542
Latest member
Bricklin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top