Calculate difference between two dates based on year selection

vikrampnz

Board Regular
Hello

I am trying to figure out if there is a way I can calculate "number of months" between two dates , but display it year wise.

For example, I have Start Month as "Aug-18" in A1 and Current Month automatically displayed as "Oct-20" in B1. When I use DATEDIF function, it gives me 26 as number of months.

I am trying to achieve a way where I can have yearwise split of no. of months i.e.

2018 - 4
2019 - 12
2020 - 10

I am having a different monthly rate for each year, which I want to apply to no. of months in that year to calculate accrued amount, hence the split.

Here's the example:

2018 - 4 * 7000 = 28,000
2019 - 12 * 7500 = 90,000
2020 - 10 * 8000 = 80,000

Can anyone suggest a way I can get number of months by the calender year?

Thanks

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Dave Patton

Well-known Member
You can custom format the dates as Year or to your preference.

T202010a.xlsm
ABCDEF
1Start31-Dec-1731-Dec-1831-Dec-1931-Oct-20
225-Aug-1841210
3Rate7,000.007,500.008,000.00
428,000.0090,000.0080,000.00
1d
Cell Formulas
RangeFormula
D1:F1D1=MIN(EOMONTH(TODAY(),0),EDATE(C1,12))
D2:F2D2=DATEDIF(MAX(\$B2,C1)-1,D1,"m")
D4:F4D4=D2*D3

Replies
5
Views
352
Replies
1
Views
345
Replies
2
Views
90
Replies
5
Views
88
Replies
14
Views
214

1,127,861
Messages
5,627,307
Members
416,239
Latest member
Counselor85027

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.

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

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