# DATEDIF Function in Excel with Examples

0
61

### How to Use Excel’s DATEDIF Function

Excel is one of the most popular spreadsheet programmes in the world. It has many features that make it easier to work with data. One of these functions is DATEDIF, which can be used in different ways to figure out the difference between two dates.

### What does the Excel DATEDIF function do?

The DATEDIF function in Excel is a way to figure out how much time has passed since two dates. The function gives you the difference between the start date and the end date in days, months, or years.

Here’s how to write the code for the DATEDIF function:

`=DATEDIF(start date, end date, "unit")`

Where “start date” is the start date, “end date” is the end date, and “unit” is the unit of time you want to use to find the difference between the two dates.

Any of the following can be the “unit” argument:

“d” for days
“m” means “month,”
“m” means “month,”
“yd” for the number of days besides the years
“ym” for the number of months that doesn’t include the year
DATEDIF Function Examples in Excel
Let’s look at some examples to see how the DATEDIF function works.

Example 1: Figuring out the number of days between two dates
In cells A1 and B1, you have two dates. Use the following formula to figure out how many days are between these two dates:

`=DATEDIF(A1, B1, "d")`

This will tell you how many days separate the two dates.

How to Figure Out the Difference in Months
Use the following formula to figure out how many months are between two dates:

`=DATEDIF(A1, B1, "m")`

This shows how many full months are between the two dates.

Example 3: Figuring out the number of years between two dates
Use the following formula to figure out how many years are between two dates:

`=DATEDIF(A1, B1, "y")`

This will tell you how many full years have passed since the two dates.

Example 4: Figuring out the difference in days without taking into account months
Use the following formula to figure out how many days are between two dates if you leave out the months:

`=DATEDIF(A1, B1, "md")`

This will return the number of days between the two dates, but not the months.

Example 5: Figuring out the difference in days without taking into account years
Use the following formula to figure out how many days are between two dates if you leave out the years:

`=DATEDIF(A1, B1, "yd")`

This will return the number of days between the two dates, but not the years.

Example 6: Figuring out the difference in months without taking years into account
Use the following formula to figure out how many months are between two dates if you leave out the years:

`=DATEDIF(A1, B1, "ym")`

This will return the number of months between the two dates, without the years.

The DATEDIF function in Excel can be used in a number of ways to figure out the difference between two dates. You can use the function to quickly and easily figure out the difference in days, months, or years. No matter what you’re doing,