How to Use DATEDIF Function in Excel (6 Suitable Examples)

In this article, we will demonstrate how to use the DATEDIF function to calculate the difference between two particular dates, whether in days, months, or years.


Download Practice Workbook


Introduction to the DATEDIF Function

The DATEDIF function determines how many days, months, or years there are between two dates. It takes as arguments an initial date, a final date, and a unit that defines whether the difference will be in days, months or years.

  • Generic Syntax

DATEDIF(start_date,end_date,unit)

  • Argument Description
ARGUMENT REQUIREMENT EXPLANATION
start_date Required The initial date or the beginning of a particular period.
end_date  Required The final date of the particular period.
unit  Required The type of information the formula should return.

6 Suitable Examples Using the DATEDIF Function in Excel

Example 1 – Calculating the Difference Between Two Dates in Days

Steps:

  • Click on cell D5 and enter the following formula:
=DATEDIF(B5,C5,"d")
  • Press Enter.

inserting formula to use datedif function in excel

  • The difference between the dates is returned in days unit.
  • Drag the Fill Handle down to fill the rest of the cells in the column.

calculating difference in days formula to use datedif function in excel

Read More: How to Use DATE Function in Excel (8 Examples)


Example 2 – Calculating the Difference Between Two Dates in Months

Steps:

  • Click on cell D5 and enter the following formula:
=DATEDIF(B5,C5,"m")
  • Press Enter.

typing formula to use datedif function in excel

We have the difference in months unit.

  • Drag the cursor down to fill the rest of the cells in the column.

evaluating difference in months to use datedif function in excel

Read More: How to Use Excel MONTH Function (6 Examples)


Example 3 – Calculating the Difference Between Two Dates in Years

Steps:

  • Click on cell D5 and enter the following formula:
=DATEDIF(B5,C5,"y")
  • Press Enter.

writing in formula to use datedif function in excel

The difference in years is returned.

  • Drag the cursor down to Auto-fill the rest of the cells in the column.

determining differences in years to use datedif function in excel

Read More: How to Use YEAR Function in Excel (5 Examples)


Similar Reading


Example 4 – Estimating Differences in Days, Ignoring Months and Years

Now we will use the DATEDIF function to calculate the difference between two dates in days, ignoring the months and years.

Steps:

  • Click on cell D5 and enter the following formula:
=DATEDIF(B5,C5,"md")
  • Press Enter.

The difference in days after ignoring the months and years is returned.

  • Drag the cursor down to the last cell in the column.

Read More: How to Use DAYS Function in Excel (7 Examples)


Example 5 – Calculating the Difference in Months, Ignoring the Years

Steps:

  • Click on cell D5 and enter the following formula:
=DATEDIF(B5,C5,"ym")
  • Press Enter.

The difference in months after ignoring the years is returned.

  • Drag the cursor down to the last cell in the column.

Example 6 – Calculating the Difference in Days, Ignoring the Years

Steps:

  • Click on cell D5 and enter the following formula:
=DATEDIF(B5,C5,"yd")
  • Press Enter.

The difference in days after ignoring the years is returned.

  • Drag the cursor down to the last cell in the column.


Related Articles

Get FREE Advanced Excel Exercises with Solutions!
Taryn Nefdt
Taryn Nefdt

Taryn is a Microsoft Certified Professional, who has used Office Applications such as Excel and Access extensively, in her interdisciplinary academic career and work experience. She has a background in biochemistry, Geographical Information Systems (GIS), and biofuels. She enjoys showcasing the functionality of Excel in various disciplines. She has over ten years of experience using Excel and Access to create advanced integrated solutions.

2 Comments
  1. HAVE YOU ENCOUNTERED any problems using MD?

    • Reply Avatar photo
      Md. Abdur Rahim Rasel Jun 25, 2023 at 12:47 PM

      Hi SANDEEP KOTHARI!
      I have not encountered any problems while using MD. If you face any problems, please send us your Excel file.
      Thank you for being with us.

      Regards
      Md. Abdur Rahim Rasel
      Exceldemy Team

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo