Calculating Date Differences in Excel

DATEDIF function in Microsoft Excel

Calculating DATE differences

We can calculate the no. of days, weeks, months & years by using excel’s built in DATEDIF function.

Microsoft has not provided a proper documentation for the DATEDIF function, hence to understand its syntax we have made it easier for you. 

The Syntax for DATEDIF:

=DATEDIF(start_date, end_date, type)

Arguments:

  • Start_date: Give the starting date in Date format to avoid any errors. You can format the date using format cells. Use DATE function to enter date without any errors.
  • End_date: Give the end date for which you want to calculate the years, days, weeks or months with respect to the starting date.
  • Type: It takes the type in which format you want to process the output.

Various “type” options:

TypeMeaningDescription
YYearsCalculates the number of years between the given dates.
MMonthsCalculates the number of complete months between the dates.
DDaysCalculates the number of days between the given dates.
MDDays excluding years and monthsIt ignores the month and years and gives the date difference in days only.
YDDays excluding yearsThe date difference in days, ignoring years.
YMMonths excluding days and yearsThe “ym” returns the number of remaining months past the last full year.

Warning: If the Start_date is greater than the End_date, the result will be #NUM!.

Let us learn DATEDIF by some examples:

Difference in Days

Suppose we have the following data which shows start dates and due dates for the subscription of various platforms.

Let’s now calculate the differences between the start date and due dates in Days.

For this we are using the below formula to determine the no. of days between the dates:

=DATEDIF(B2,D2,”D”)

and copying it to other relevant cells.

We get,

The following Output

:

Here, we can clearly see that we were successful in calculating the no. of days in between the start and end dates.

Difference in Weeks

Proceeding with the same example data.

Applying the below formula in E2 and copying it till E7:

=DATEDIF(B2,D2,”D”)

We got:

Oopsie doopsie! We got something else, but this is not an error the result needs to be formatted in number to display the no. of weeks.

To Resolve this issue:

  • Select all the Cells of Date Difference
  • Press CTRL + 1. 
  • Then click Number Decimal places: 2
  • Then Click on OK

And see the result,

Yay! We successfully got our desired results.

Difference in Months

Proceeding with the data set in the previous example, we will now try to calculate the no. of months between the given dates.

Applying the below formula:

=DATEDIF(B2,D2,”M”)

We get,

Again, don’t forget to format your result if you got something else. This time I have formatted with numbers having 0 decimal places.

Difference in Years

Yet again going with the above example data, this time to calculate the date difference in Years. For this to have proper results we are increasing the due-dates of our subscription for this example.

Applying the below formula:

=DATEDIF(B2,D2,”y”)

We get,

So, you can use the above examples to set up your own worksheet to work with date differences.

Hope, you liked this article.

Keep Learning!

Are you looking for a full fledged training? You are at the right place.

At TechnoExcel :

You can upskill yourself with:

Why us?

Techno Excel is a leading provider of Excel courses and data analytics courses. We not only teach you how to use excel but also help customize it for your exact needs! Make the most out of your career with Techno Excel. Students can join via classroom course or via Online course. This is the place where students can easily learn the required skill set to get placed immediately

Learn data science and other technologies at your convenient time. We have a flexible schedule, which is designed to suit your learning style and pace. Whether you are a beginner or a professional looking for advanced techniques, we have the right course for you. Hurry up!! Book your seat now!!!

Class-room of your choice

Upskill yourself by attending classroom or online class.

Flexible timings

Learn at your convenient time. We have a flexible schedule, which is designed to suit your learning style and pace.

Class-Room Size

With limited students in class, attention to each student's performance will be given.

Industry Ready Curriculum

The course is designed for people who want to work in the industry.

Book your free consultation now

If you want to improve your skills and get ready for the workforce! Please enter your information below, and one of our expertise will contact you shortly.

    Leave a Comment

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