I am trying to create a formula or VBA function which calculates the number of months between two dates, according to this rule: if the start date is the 15th of the month or before, or the end date is after the 15th of the month, then that month counts.
For example:
Start Date End Date Output
---------- --------- --------
1/5/2014 2/16/2014 2 months
1/17/2014 2/16/2014 1 month
1/16/2014 2/5/2014 0 months
I have already tried =DATEDIF(A2, B2, "M") + IF( DATEDIF(A2, B2, "MD")>=15, 1, 0)
but this only adds a month if the distance between the days in 2 dates is over 15. For example if the start date is 5/14/13-8/16/13 it will say that there are 3 months in between these dates. However, the actual distance between these 2 dates should be 4 months according to the conditions that I specified above.
Ho do I fix this formula?
MONTH
can be used as you see in the answer you accepted. Another point: 1/14/2014 to 2/16/2014 should return 2 months? Are you sure this is what you want? – Jean-François Corbett