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

Method 1 – Using DATEDIF Function

1.1. Applying DATEDIF Function 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.

  • 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.

1.2. Customizing DATEDIF Function

NLearn how to customize the DATEDIF function to find out the number of years, months, and days between two dates.

Create the following formula by customizing the DATEDIF function to find 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

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.


Method 2 – Inserting YEARFRAC Function 

2.1. YEARFRAC Wrapped with INT Function

The INT function is used to get the nearest integer. Wrapping up the YEARFRAC function with the INT function will turn the year’s fractional value into an integer.

Apply the following formula to a selected cell.

=INT(YEARFRAC(C5,D5,3)*12)
  • C5 = Launch Date,
  • D5 = Closing Date,
  • 3 = 365-day count basis.

YEARFRAC function to find Number of Months Between Dates in Excel

Formula Breakdown

We’re finding out the number of years as time span first which will be shown in decimal format. 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.

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


2.2. YEARFRAC Function Wrapped with ROUNDUP Function

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)
  • C5 = Launch Date,
  • D5 = Closing Date.

The INT function doesn’t round off the decimal value, so it omits the decimal parts even if it’s too close to the next integer value.

The ROUNDUP function allows you to round off the number up to a fixed decimal place or the nearest whole number, according to your choice.


Method 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)
  • 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.

Method 4 – Subtracting MONTH Functions

We’ll combine multiple MONTH functions with a simple subtraction formula.

Subtract an old date from a new date by using the MONTH function for both dates, and you’re done.

=MONTH(D5)-MONTH(C5)
  • 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.

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.


Further Readings


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

Get FREE Advanced Excel Exercises with Solutions!
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