# calculate years and months between two dates

Posted on Posted in the ritz carlton yacht collection

\n

The formula that you use to find out the time between two dates in years and months uses a text string with two DATEDIF functions.

\n

Cell C4 shown contains the following formula:

\n\n
`=DATEDIF(A4,B4,\"Y\") & \" Years, \" & DATEDIF(A4,B4,\"YM\") & \" Months\"`
\n

You accomplish this task by using two DATEDIF functions joined in a text string with the ampersand (&) operator.

\n

The first DATEDIF function calculates the number of years between the start and end dates by passing the year time unit (Y):

\n
`DATEDIF(A4,B4,\"Y\")`
\n

The second DATEDIF function uses the \"YM\" time unit to calculate the number of months, ignoring the year portion of the date:

\n
`DATEDIF(A4,B4,\"YM\")`
\n

Finally, you join these two functions with some text of your own to let users know which number represents years and which represents months:

\n
`=DATEDIF(A4,B4,\"Y\") & \" Years, \" & DATEDIF(A4,B4,\"YM\") & \" Months\"`