Sometimes you want count the days, months, years… between two dates. For example, you are expecting a child and you may want to know how old he/she in terms of days, months.

Well, Excel has a very useful function for this task. Let’s take a look at the DATEDIF function.

## How does it work?

The function takes three arguments, the first one is the beginning date, the second one is the end date and the last one is the unit you want to see the result in (days, months, years…)

Let’s look at an example:

As you can see, the start date is Jan-2001, the end date is Jan-2018 and the function asks for the difference in year. The result, as you can guess:

It’s 17 years.

How about we want to calculate the difference between to dates in months?

Let’s give it a try

And the result is:

7 months, as you can see.

There are different values you can pass in the third arguments such as:

d: for number of days

md: the difference in days, ignoring number of years and months. So, if you compare the difference in days using “md” between 01/01/2017 and 15/01/2017, you would get the same result as the difference between 01/01/2017 and 15/01/2018

ym: the difference in month, year and days are ignored

yd: the difference in days. The result always less than 365 since the year count is ignored.

So, you’ve learned how to calculate difference between two days in different units.