How to Calculate Number of Months Between Two Dates in Excel

Get FREE Advanced Excel Exercises with Solutions!

Microsoft Excel is one of the greatest tools that allows you to find the number of months between any two dates by providing a number of unique functions. Through these functions, you’ll be able to find out the time span of any incident or someone’s age at once by inserting two fixed dates only.


Number of Months Between Two Dates in Excel: 4 Easy Methods

Let’s say, we have a dataset of some projects launched by an organization, the launching and closing dates of these projects.

Dataset to Find Number of Months Between Two Dates in Excel

We want to find out the number of months taken to close the project. We will discuss the ways in which our purpose can be served.

In this section, you will be familiar with 4 easy methods to find the number of months between two dates in Excel. I will discuss them with proper illustrations here. Let’s check them now!


1. Using DATEDIF Function

The DATEDIF function returns the difference of days, months, or years between two dates, based on three arguments, one starting end, one ending date, and one argument called unit. We will show the direct and customized form of this function to find out the number of months between the concerning dates.


1.1. Applying DATEDIF Function Directly

We have to find the number of months as the time span of all projects. We’ll use the DATEDIF function here directly.

🖊️ Steps

  • Select cell E5 where you want to find the time span as months and type the following formula in that cell.
=DATEDIF(C5,D5,"M")

Here,

  • C5 = Launch Date,
  • D5 = Closing Date,
  • M = The parameter for the number of months to be counted in this function.

DATEDIF function to Find Number of two Months Between Dates in Excel

📃Note: This function will not calculate the running month, but will stop at the previous completed month.
  • Press Enter and you’ll get the number of months as a time span for the first project in cell E5.
  • Drag the Fill Handle tool down to autofill the formula for the other cells.

  • Hence, all the cells will bring you the number of months from calculating these two dates.

📃Note: If we use Y (Years) or D (Days) in lieu of M (Months) in the parameter part inside the function bar, we’ll get the differences between two dates as a number of years or days too.

Read More: How to Count Months from Date to Today by Using Excel Formula


1.2. Customizing DATEDIF Function

Now you’ll be able to learn how you can find out the number of years, months, and days together between two dates by customizing the DATEDIF function.

Just, create the following formula by customizing the DATEDIF function for finding the number of months between the encountered dates and apply it to your data.

=DATEDIF(C5,D5,"Y")&" Year(s) "&DATEDIF(C5,D5,"YM")&" Month(s) "& DATEDIF(C5,D5,"MD")&" Day(s)"

Here,

  • C5 = Launch Date,
  • D5 = Closing Date,
  • Y = Number of Years,
  • MD = Number of Days ignoring Months,
  • YM = Number of Months ignoring Years.

🗯️Formula Breakdown

Here we’re using DATEDIF functions again but this time we’ll add some text functions like Year(s) by using Ampersand (&) which will create spaces between words or number(s).

Before 3 units of time, we’re using the DATEDIF function every time to find out the number of years, months, and days separately.

Read More: Excel Calculates Difference Between Two Dates in Days


2. Inserting YEARFRAC Function 

Now we’re going to use the YEARFRAC function to work with the previous dataset. The YEARFRAC function returns the year fraction representing the number of whole days between start_date and end_date on the basis of whole_days.


2.1. YEARFRAC Wrapped with INT Function

The INT function is used to get the nearest integer. So, wrapping up the YEARFRAC function with the INT function will turn the fractional value of the year into an integer.

So, apply the following formula to a selected cell.

=INT(YEARFRAC(C5,D5,3)*12)

Here,

  • C5 = Launch Date,
  • D5 = Closing Date,
  • 3 = 365-day count basis.

YEARFRAC function to find Number of Months Between Dates in Excel

🗯️Formula Breakdown

Here, we’re finding out the number of years as time span first which will be shown in decimal format. Then this value will be multiplied by 12 (No. of months in a year). We’ll use the INT function at the initial to convert decimal into integer format.

You’ll see the same result as found before.

  • Now, drag the formula again like before to find out the number of months as the time span for the rest of the projects.

Read More: How to Calculate Years Between Two Dates in Excel


2.2. YEARFRAC Function Wrapped with ROUNDUP Function

We can use the ROUNDUP function instead of the INT function too at the initial. But there’s a difference between these 2 functions.

=ROUNDUP(YEARFRAC(C5,D5,3)*12,0)

Here,

  • C5 = Launch Date,
  • D5 = Closing Date.

The INT function won’t round off the decimal value so it’ll omit the decimal parts even if it’s too close to the next integer value.

But the ROUNDUP function will allow you to round off the number up to a fixed decimal place or the nearest whole number according to your choice.

Read More: How to Find Number of Weeks Between Two Dates in Excel


3. Combining YEAR and MONTH Functions 

Here’s another method you can also use to get the same results. And we’ll combine YEAR and MONTH functions in this method. The YEAR function returns the year of a date, an integer in the range 1900-9999. The MONTH function returns the month, a number from 1 (January) to 12 (December).

Apply the following formula to get the number of months.

=(YEAR(D5)-YEAR(C5))*12+MONTH(D5)-MONTH(C5)

Here,

  • C5 = Launch Date,
  • D5 = Closing Date.

YEAR and MONTH function to Find Number of Months Between Dates in Excel

🗯️Formula Breakdown

What we’re doing here in cell E5 is-

  1.  Finding the differences between years,
  2. Converting years into months,
  3. Adding differences between the ranks or orders of two months.

Read More: Calculate Years and Months Between Two Dates in Excel


4. Subtracting MONTH Functions

In this last part of all methods, we’ll now combine multiple MONTH functions with a simple subtraction formula.

What you have to do here is subtract an old date from a new date by using the MONTH function for both dates and you’re done.

=MONTH(D5)-MONTH(C5)

Here,

  • C5 = Launch Date,
  • D5 = Closing Date.

Note: This method has a drawback. It’ll allow you to find the number of differences between two months only within a fixed year.

Read More: Excel Formula to Count Days from Date


Months Calculator for Two Dates

Here, I am providing you a calculator in which you can just input dates and get the number of months between the dates.


Download Practice Workbook

You can download our Excel workbook which we’ve used to prepare this article. You can also use this practice book as a calculator by inputting dates in the specific fields to work out the number of months between two dates as instructed.


Conclusion

In this article, I’ve tried to illustrate each of the methods to calculate the number of months between two dates in Excel in a convenient way as possible. I hope this article has guided you through the proper instructions thoroughly. If you have any question(s) or feedback regarding this article you can comment. You can also go through other useful articles related to basic and advanced Excel functions on our website.


Further Readings


<< Go Back to Days Between Dates | Calculate Dates | Date-Time in Excel | Learn Excel

What is ExcelDemy?

ExcelDemy - Learn Excel & Get Excel Solutions Center provides online Excel training , Excel consultancy services , free Excel tutorials, free support , and free Excel Templates for Excel professionals and businesses. Feel free to contact us with your Excel problems.
Nehad Ulfat
Nehad Ulfat

NEHAD ULFAT is an excellent marine engineer who loves working with Excel and diving into VBA programming. For him, programming is like a tool that saves time when dealing with data, files, and the internet. His skills go beyond the basics, including ABACUS, AutoCAD, Rhinoceros, Maxsurf, and Hydromax. He got his B.Sc in Naval Architecture & Marine Engineering from BUET but switched gears, working as a content developer.  In this role, he creates techy content all about Excel... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo