Month difference between 2 dates

jaycee

Active Member
Joined
Jul 22, 2009
Messages
323
I need to find the number of months between 2 dates, I have tried "DATEDIF" but this does not give what I require, below is what is needed


<tbody>
[TD="width: 39%"] A1
[/TD]
[TD="width: 36%"] B1
[/TD]
[TD="width: 25%"] Months
[/TD]

[TD="width: 39%"] 01/01/2017
[/TD]
[TD="width: 36%"] 29/01/2017
[/TD]
[TD="width: 25%"] 1
[/TD]

[TD="width: 39%"] 01/01/2017
[/TD]
[TD="width: 36%"] 01/02/2017
[/TD]
[TD="width: 25%"] 2
[/TD]

[TD="width: 39%"] 01/01/2017
[/TD]
[TD="width: 36%"] 28/02/2017
[/TD]
[TD="width: 25%"] 2
[/TD]

[TD="width: 39%"] 01/01/2017
[/TD]
[TD="width: 36%"] 01/03/2017
[/TD]
[TD="width: 25%"] 3
[/TD]

</tbody>
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Hi jaycee,

How about using this formula:

=MONTH(B1)-MONTH(A1)

This is returning a value 1 less than what you expect, so you might wanna add "+1" to the end.

Hope it helps you.
 
Upvote 0
Take a look at this:


Book1
ABCD
1A1B1Months
21-1-201729-1-201711,00
31-1-20171-2-201722,00
41-1-201728-2-201722,00
51-1-20171-3-201733,00
Sheet1
Cell Formulas
RangeFormula
D2=ROUNDUP(YEARFRAC(EOMONTH(A2,-1)+1,EOMONTH(B2,0),3)*12,0)
 
Upvote 0
So looking at your table it seems like you are counting any part of a month as a month, so 1/1/2016 to 1/1/2017 should count as 13, right?

Is the start date always 1st of the month, if so try

=DATEDIF(A2,B2,"m")+1

otherwise for any start date

=DATEDIF(A2-DAY(A2)+1,B2,"m")+1
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,185
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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