Excel DATEDIF formula to show time gap between two dates

You can use the DATEDIF formula to calculate the number of years, months, or days between dates entered in two different cells in an Excel spreadsheet.

So, if we use the formula: =DATEDIF(A2,B2,"Y")

. . . it will show the number of years between one date in cell A2 and a later date in B2. The result will only show the full number of years. So in this example:

. . . only three years are shown between November 8, 2016 and November 3, 2020 because it has been five days short of 4 years.

If the letter in parentheses at the end of the formula is changed from a Y to a M, the number of months will be shown.


Changing to a D will result in the number of full days being shown in the designated date range.