The Excel DATEDIF function helps to calculate the months & years between two dates.
In below example, the older date is in cell C6, and the newer date is in B6. The formula is in D6. The “m” returns the number of complete months between the two dates.

In below example, the older date is in cell C6, and the newer date is in B6. The formula is in D6. The “y” returns the number of complete years between the two dates.

Warning: If the older_date is greater than the newer_date, the result will be #NUM!.