YEARFRAC

 

Detailed Process Flow to Use the YEARFRAC Function in Excel

What is the YEARFRAC Function?

The YEARFRAC function in Excel calculates the fraction of the year between two dates. It is useful for:
✅ Calculating age from the date of birth (as seen in the image).
✅ Determining the exact number of years between two dates.
✅ Financial calculations like interest accruals or service periods.


Syntax of the YEARFRAC Function 

=YEARFRAC(start_date, end_date, [basis])
  • start_date → The beginning date (e.g., Date of Joining).
  • end_date → The ending date (e.g., TODAY() for current age).
  • [basis] (optional) → Determines the method of calculation. Default is 0 (US 30/360).
BasisDescription
0US (NASD) 30/360
1Actual/Actual
2Actual/360
3Actual/365
4European 30/360

To calculate age, we use basis 1 (Actual/Actual).


Step-by-Step Process to Use YEARFRAC in Excel

Step 1: Select the Cell for the Age Calculation

Click on the first cell in the "Age" column where the result should appear (e.g., E2 in the table).

Step 2: Enter the YEARFRAC Formula

Use the formula to calculate age: 

=YEARFRAC(D2, TODAY(), 1)
  • D2 → Contains the Date of Joining (DOJ).
  • TODAY() → Returns the current date dynamically.
  • 1 → Uses the Actual/Actual basis for precise calculation.

Step 3: Round the Age to the Nearest Whole Number

Since age is typically represented in whole years, we round it using: 

=ROUND(YEARFRAC(D2, TODAY(), 1), 0)

This ensures the result is a whole number.

Step 4: Drag the Formula Down

  • Click on the small square at the bottom-right corner of the selected cell.
  • Drag it down to apply the formula to the entire column.

Sample Data with Applied Function

Sr.NoEmp.CodeNameD.O.JFormula AppliedAge (Result)
14023Employee 1304/07/1984=ROUND(YEARFRAC(D2, TODAY(), 1),0)41
24023Employee 705/05/2003=ROUND(YEARFRAC(D3, TODAY(), 1),0)22
34011Employee 1105/05/2003=ROUND(YEARFRAC(D4, TODAY(), 1),0)22
44017Employee 505/04/2003=ROUND(YEARFRAC(D5, TODAY(), 1),0)22
54015Employee 405/02/1984=ROUND(YEARFRAC(D6, TODAY(), 1),0)41
64015Employee 803/01/2003=ROUND(YEARFRAC(D7, TODAY(), 1),0)22
74016Employee 618/11/2002=ROUND(YEARFRAC(D8, TODAY(), 1),0)22
84024Employee 1516/09/2002=ROUND(YEARFRAC(D9, TODAY(), 1),0)22
94003Employee 1205/06/2002=ROUND(YEARFRAC(D10, TODAY(), 1),0)23
104025Employee 930/04/2002=ROUND(YEARFRAC(D11, TODAY(), 1),0)23
114014Employee 121/03/2002=ROUND(YEARFRAC(D12, TODAY(), 1),0)23
124022Employee 1016/01/2002=ROUND(YEARFRAC(D13, TODAY(), 1),0)23
134007Employee 325/10/2001=ROUND(YEARFRAC(D14, TODAY(), 1),0)23
144040Employee 206/05/2001=ROUND(YEARFRAC(D15, TODAY(), 1),0)24
154029Employee 1408/05/2000=ROUND(YEARFRAC(D16, TODAY(), 1),0)25

Key Benefits of Using YEARFRAC

Accurate Age Calculation → Works for birthdays and employment years.
Real-time Updates → Uses TODAY() to keep values current.
Flexible Basis Options → Can be adjusted for financial applications.


Conclusion

The YEARFRAC function is an efficient way to calculate age or duration between two dates. Combining it with ROUND ensures the values are in whole years.