Here are a few examples of the results that YEARFRAC calculates: In the example shown, the formula in D6 is:

Rounding results

Once you have the decimal value, you can round the number if you like. For example, you could round to the nearest whole number with the ROUND function:

Whole years only

You might also want to keep only the integer portion of the result with no fractional value, so that you are only counting whole years. In that case, you can just wrap YEARFRAC in the INT function: If you need to calculate years on an ongoing basis, for example to get age based on a birthday, see the example here. Note: The YEARFRAC function has an optional 3rd argument that controls how days are counted when computing fractional years. The default behavior is to count days between two dates based on a 360-day year, where all 12 months are considered to have 30 days. The YEARFRAC page provides more information.

Dave Bruns

Hi - I’m Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.