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!
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!