0

I have two columns one for start date and one for end date. I am try to an automatic calculation of the months between the to dates. However if the start date is 15th or after it counts as the next month (example 01/15/16 would count as February).

I was thinking an if formula if the start date is days 1:14 than

IF(D6<14,(year(e6)-year(d6))*12+month(e6)-month(d6),(year(e6)-year(d6))*12+month(e6)-month(d6)+1). but I cannot get it to work.

enter image description here

Any other suggestions?

2
  • Please share the actual formula, it will help us see what is going on (wrong). Please edit your question don't post your formula as a comment :) Your title is about MS office, but I assume it's a typo and should be MS Excel 2010? I made the edit, roll back if you don't like it
    – Dave
    Commented Jun 10, 2016 at 14:37
  • The solution is likely simlar to =IF(A1>B1,A1-B1,B1-A1), assuming A1 and B1 has the start and end dates
    – Dave
    Commented Jun 10, 2016 at 14:40

2 Answers 2

2

You can use the DATEDIF function inside an `IF statement to do this.

In F6 use the IF statement to check if the "start date is 15th or after", which the result will modify the DATEDIF calculation.

=IF(DAY(D6)>=15, DATEDIF(D6,E6, "m")-1, DATEDIF(D6,E6, "m"))

This checks if the Start Date to see if the day is greater than 15. If it is it uses the DATEDIF function to calculate the months, minus 1 month.

enter image description here

If the day is not greater than 15, it uses the standard DATEDIF calculation.

enter image description here

Note: my images use differnet cells.

1
1

There's a very simple way:

=(E6-D6)/30.4375

The result will tell you how many months have passed between the 2 dates. The number with which it's divided is the average number of days in a year over 4 years (to include 1 leap year).

This works because of the way Excel stores dates. It's actually stored as a number of days passed since 1/1/1900 so arithmetic operations work.

Note that if you set number type to not show decimals it would round 16 days to full month. If you want to avoid this, just round it down, and then the result will be number of full months passed:

=INT((E6-D6)/30.4375)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .