Count number of months per year between two dates

BenB0425

New Member
Joined
Sep 17, 2019
Messages
6
I was looking for some help with a formula. I want to count the number of months between two dates and have them be separated by the year. I received a formula but all it did was count the months and put them in the last year column. The formula that I am using is below. It works in my test sample when I type in the dates but not when I pull them from our data source.

=IFERROR(DATEDIF(MAX($F2,DATE(K$1-1,12,31)),MIN($G2,DATE(K$1,12,31)),"m")+1,0)


Column F Column H Column I
(End Date) (Begin Date) (Number of months Counted) 2011 2012 2013 2014 2015 2016

[TABLE="width: 1580"]
<colgroup><col><col><col><col><col><col span="9"></colgroup><tbody>[TR]
[TD]3/1/2019[/TD]
[TD]09/1/2018[/TD]
[TD][/TD]
[TD]7[/TD]
[TD][/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]10[/TD]
[/TR]
[TR]
[TD]3/1/2019[/TD]
[TD]08/1/2018[/TD]
[TD][/TD]
[TD]8[/TD]
[TD][/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]10[/TD]
[/TR]
[TR]
[TD]3/1/2019[/TD]
[TD]08/1/2018[/TD]
[TD][/TD]
[TD]8[/TD]
[TD][/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]10[/TD]
[/TR]
[TR]
[TD]3/1/2019[/TD]
[TD]07/1/2018[/TD]
[TD][/TD]
[TD]9[/TD]
[TD][/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]10[/TD]
[/TR]
[TR]
[TD]3/1/2019[/TD]
[TD]06/1/2018[/TD]
[TD][/TD]
[TD]10[/TD]
[TD][/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]10[/TD]
[/TR]
[TR]
[TD]3/1/2019[/TD]
[TD]04/1/2018[/TD]
[TD][/TD]
[TD]12[/TD]
[TD][/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]10[/TD]
[/TR]
[TR]
[TD]3/1/2019[/TD]
[TD]02/1/2018[/TD]
[TD][/TD]
[TD]14[/TD]
[TD][/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]10[/TD]
[/TR]
[TR]
[TD]3/1/2019[/TD]
[TD]06/1/2016[/TD]
[TD][/TD]
[TD]34[/TD]
[TD][/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]10[/TD]
[/TR]
[TR]
[TD]3/1/2019[/TD]
[TD]11/1/2018[/TD]
[TD][/TD]
[TD]5[/TD]
[TD][/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]10[/TD]
[/TR]
[TR]
[TD]3/1/2019[/TD]
[TD]11/1/2018[/TD]
[TD][/TD]
[TD]5[/TD]
[TD][/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]10[/TD]
[/TR]
</tbody>[/TABLE]


So I need a formula that with count the number of months in years 2011 - 2019. Hopefully the formula will state zeros for the years with no months and the years that the dates have months just compute those months. But as you can see the 2019 column has a higher number then it should be and the other years are not calculating.

Does that make sense? Is there any help out there
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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