How to Use YEARFRAC Function in Excel + Tips (Video in Khmer)
Learn how to use YEARFRAC function in Excel step-by-step to calculate fraction of year between two dates with simple examples and video tutorial.
Hello everyone! Today i will show you how to use YEARFRAC function in Microsoft Excel step by step. Very easy and useful formula for calculating age, work experience, or interest fraction between two dates! YEARFRAC is available in all Excel versions, Excel 365, and Excel for Web.
1. What is YEARFRAC Function in Excel?
The YEARFRAC function calculates the fraction of a year (in decimal numbers) between a start date and an end date.
Think of YEARFRAC like measuring date distance in year units:
- Exactly 6 months difference ➔ returns
0.5years. - Exactly 1 year and 3 months difference ➔ returns
1.25years. - Calculate exact age or work experience (e.g.
25.75years old)!
2. 🛠️ Formula Syntax & Parameters
=YEARFRAC(start_date, end_date, [basis])
start_date: Required. The starting date.end_date: Required. The ending date.[basis]: Optional. The type of day count logic to use:0(or omit) =US (NASD) 30/360(Default).1=Actual/actual(Most accurate for exact real-world age & interest!).2=Actual/360.3=Actual/365.4=European 30/360.
3. 📋 Practical Examples
Example 1: Calculate Exact Fraction of Year Between 2 Dates
Suppose cell A2 contains 2026-01-01 and cell B2 contains 2026-07-01 (6 months):
=YEARFRAC(A2, B2)
👉 Result: Returns 0.5 (half a year)!
Example 2: Calculate Exact Age from Birthday
Combine YEARFRAC with TODAY() to get exact age:
=YEARFRAC(A2, TODAY(), 1)
If birth date in A2 is 2000-05-15 and TODAY is 2026-09-21:
👉 Result: Returns 26.35 years!
💡 Want integer age only (no decimal)? Wrap inside
INT():=INT(YEARFRAC(A2, TODAY(), 1))👉 Result:
26years old!
Example 3: Calculate Employee Work Tenure / Experience
Calculate how many years an employee has worked at the company:
| Row | Column A (Employee) | Column B (Join Date) | Column C (End Date) | Formula | Result |
|---|---|---|---|---|---|
| 2 | Sokha | 2021-01-01 | 2026-07-01 | =YEARFRAC(B2, C2) | 5.5 years |
| 3 | Bopha | 2023-03-15 | TODAY() | =YEARFRAC(B3, TODAY(), 1) | 3.52 years |
💡 Quick Tips for Using YEARFRAC Function
- Use
basis = 1for Real-World Accuracy: Setting the 3rd parameter[basis]to1uses actual days divided by actual year length (365 or 366 for leap year), giving the most accurate results for age and bank interest calculations. - Order of Dates Does Not Matter: Whether
start_dateis earlier or later thanend_date,YEARFRACalways returns a positive fraction! - Use
INT()orROUND()to Remove Decimals: If you need full whole years only (like age on passport), use=INT(YEARFRAC(start_date, end_date)). - Fix
#VALUE!Error: If Excel returns#VALUE!, check if your date cells are real Excel date serial numbers and not formatted as plain text strings.
📚 Related Resources & Tutorials
Related Tutorials
Opens in new tab ↗How to Use DATEVALUE Function in Excel (Video in Khmer)
Learn how to use DATEVALUE function in Excel step-by-step to convert text date to real date.
How to Use DATE Function in Excel (Video in Khmer)
Learn how to use DATE function in Excel step-by-step to build real dates from year, month, and day numbers.
How to Use the WEEKNUM Function in Excel (video in khmer)
Learn how to get the week number of the year from a date in Excel using WEEKNUM formula step by step with simple examples.