How to Use the DATEDIF Function in Excel

Introduction

Welcome to an in-depth guide on the DATEDIF function, a hidden yet incredibly useful feature in both Microsoft Excel and Google Sheets. The DATEDIF function allows you to calculate the difference between two dates in days, months, or years. Although it doesn’t appear in Excel’s function library, it remains fully operational.

Basic Syntax

The syntax for the DATEDIF function is as follows:

DATEDIF(start_date, end_date, "unit")
  • start_date: The starting date of the period.
  • end_date: The ending date of the period.
  • unit: A text parameter that defines the type of interval to return:
    • “d” or “D”: The total number of days between the two dates.
    • “m” or “M”: The total number of months between the two dates.
    • “y” or “Y”: The total number of years between the two dates.

Examples of Calculations

Let’s explore several practical examples to showcase the utility of the DATEDIF function:

Example 1: Calculate the Number of Days Between Two Dates

Consider the start date is in cell A1 (01-Jan-2022) and the end date is in cell B1 (05-Jan-2022). To calculate the number of days between these dates, use the formula:

=DATEDIF(A1, B1, "d")
Start Date End Date Result (Days)
01-Jan-2022 05-Jan-2022 4

Example 2: Calculate the Number of Months Between Two Dates

To estimate the number of months between two dates, use the formula:

=DATEDIF(A1, B1, "m")
Start Date End Date Result (Months)
01-Jan-2022 01-Mar-2022 2

Example 3: Calculate the Number of Years Between Two Dates

For determining the number of years between two specific dates, apply:

=DATEDIF(A1, B1, "y")
Start Date End Date Result (Years)
01-Jan-2020 01-Jan-2022 2

Conclusion

The DATEDIF function is a robust tool for computing differences in dates, whether in days, months, or years, across Excel and Google Sheets. While it is important to note that DATEDIF is not listed in the official documentation and may not be supported in future updates, it currently serves as an effective solution for date-related calculations.

More information: https://support.microsoft.com/en-us/office/datedif-function-25dba1a4-2812-480b-84dd-8b32a451b35c

Other functions
Returns the serial number of a particular date
Converts a date in the form of text to a serial number
Converts a serial number to a day of the month
Returns the number of days between two dates
Calculates the number of days between two dates based on a 360-day year
Returns the serial number of the date that is the indicated number of months before or after the start date
Returns the serial number of the last day of the month before or after a specified number of months
Converts a serial number to an hour
Returns the number of the ISO week number of the year for a given date
Converts a serial number to a minute
Converts a serial number to a month
Returns the number of whole workdays between two dates
Returns the number of whole workdays between two dates using parameters to indicate which and how many days are weekend days
Returns the serial number of the current date and time
Converts a serial number to a second
Returns the serial number of a particular time
Converts a time in the form of text to a serial number
Returns the serial number of today's date
Converts a serial number to a day of the week
Converts a serial number to a number representing where the week falls numerically with a year
Returns the serial number of the date before or after a specified number of workdays
Returns the serial number of the date before or after a specified number of workdays using parameters to indicate which and how many days are weekend days
Converts a serial number to a year
Returns the year fraction representing the number of whole days between start_date and end_date