Calculating Monthly Term between two Dates

dwb

New Member
Joined
Jan 28, 2020
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Can anyone suggest a formula (hopefully simple) to calculate the months and partial months between any two dates. By way of example, for start and stop dates as follows I'm looking for the following results:

1/1/2020 to 12/31/2020 should return 12.000 months
1/15/2020 to 12/31/2020 should return 11.4838 months, or partial month for January (15th/31st) plus the whole months February through December (11 months)
1/1/2020 to 12/15/2020 should return 11.4838 months, or whole months for January through November 30 (11 months) plus partial month for December (1st/15th)
1/15/2020 to 1/14/2021 should return 12.000 months
1/20/2020 to 1/10/2021 should return 11.6774, or the partial month for January (20th/31st - 11days) plus whole months February to December (11 months) plus January (1st/10th - 10days)

The formula must properly account for leap years, but only if the start or stop date falls within the month of February and must work for any date combination the stop date exceeds the start date.

Seems simple, but I am having difficulty getting the logic to work for all cases.

Thanks!
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Thank you! I did not consider using the yearfrac function. Works great!
 
Upvote 0

Forum statistics

Threads
1,214,823
Messages
6,121,779
Members
449,049
Latest member
greyangel23

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