How to find the number of months between two dates in Excel

Number of Months Between Two Dates?

How many months are between two dates? The answer is “it depends” because your real question might be one of the following:

How many months are between two days where the number is expressed as a fractional number?
How many months are between two days where we’re only counting whole months?
How many months are between two days rounding half months up to the nearest whole month?
How many months are between two days where a fractional month counts as a whole month?
How many months are between two days where days in any given month count as a whole month?

As we’ll see below, the answer to each of the questions is different. And in your case, the specific question you’re really asking may be one of the above or even another variation. In other words, the answer to the original question really is ‘it depends on what you mean’. Let’s look at each case individually below.

Quick Conventions

To make reading through the formulas below a little bit easier, let’s just agree that the names here correspond to the cells or values you’ll use in your own situation.

FirstDate will be the oldest date, and in the calculations below we’ll use March 4, 2010 as the date.

LastDate will be the lastest date, and in the calculations below we’ll use July 1, 2012.

Also note that I’m using 365.25/12 as the number of days in a month in most of these formulas.

How many months are between two dates where the number is expressed as a fractional number?

In this case we’re just getting a number, like 3.14. Think of this as just getting a more fine-grained number representing the elapsed time. Here’s the formula to use.

=(DATE(YEAR(LastDate),MONTH(LastDate),DAY(LastDate))-DATE(YEAR(FirstDate),MONTH(FirstDate),DAY(FirstDate)))/(365.25/12)

This formula gives us 27.93 as the number of months between the first and last date we’re using here.

How many months are between two dates where we’re only counting whole months?

We use the same number computation used in the fractional number question above, and then nest that in the ROUNDDOWN function to just keep the whole month part.

=ROUNDDOWN((DATE(YEAR(LastDate),MONTH(LastDate),DAY(LastDate))-DATE(YEAR(FirstDate),MONTH(FirstDate),DAY(FirstDate)))/(365.25/12),0)

This formula will give us 27 “whole” months. The fractional part of the month won’t be counted which is what we want in this situation.

How many months are between two dates rounding half months up to the nearest whole month?

In this case we’ll nest our fractional month calculation from above in the ROUND function. This will round up half months to the next highest number.

=ROUND((DATE(YEAR(LastDate),MONTH(LastDate),DAY(LastDate))-DATE(YEAR(FirstDate),MONTH(FirstDate),DAY(FirstDate)))/(365.25/12),0)

This formula will give us 28 months since that fractional month is counted as a month in this situation.

How many months are between two dates where a fractional month counts as a whole month?

In this case, we want any part of a month to count as a whole month. Similar to the above scenarios we’ll embed our fractional calculation in another function. In this case we’ll use the ROUNDUP function.

=ROUNDUP((DATE(YEAR(LastDate),MONTH(LastDate),DAY(LastDate))-DATE(YEAR(FirstDate),MONTH(FirstDate),DAY(FirstDate)))/(365.25/12),0)

This will also give us 28 months. The difference between this formula and the one right above is that we’ll be rounding up even if the fractional month only contained, say, 1 day.

How many months are between two dates where days in any given month count as a whole month?

This scenario is a bit different than the ones above. We have two basic cases here. The first is that the start and end date are in the same or adjacent years. The other scenario is when the start and end dates are separated by at least a year between them. We’ll use the IF function to test for those cases and use a slightly different formula for each case.

=IF((YEAR(FirstDate)-YEAR(LastDate))>1,(MONTH(FirstDate)+(12-MONTH(LastDate)+1)+((YEAR(FirstDate)-YEAR(LastDate)-1)*12)),(MONTH(FirstDate)+(12-MONTH(LastDate)+1)))

This function will give us 29 months. That’s 2 months different than the case where we’re rounding down to the nearest whole month! Why? Because in this case we’re counting the partial months of both the FirstDate and the LastDate and we’re looking at specific calendar months instead of defining a month to be a set of contiguous days.

So the answer really depends on how you need to count the time elapsed between two dates.

Hopefully you can use these formulas or modify some of the above for your specific needs.

There you go.

3 thoughts on “How to find the number of months between two dates in Excel

Leave a Reply

Your email address will not be published. Required fields are marked *