Excel YEARFRAC: Syntax, Basis Options and Common Pitfalls
How Excel YEARFRAC works, what each of the five basis options does, why results can differ by method, and when DATEDIF is the better choice for ages and tenure.
YEARFRAC returns the number of years between two dates as a decimal, so =YEARFRAC(DATE(2012,1,1), DATE(2012,7,30)) gives about 0.58 years. The result depends on the optional third argument, basis, which decides how days are counted. Leave it out and Excel uses the US 30/360 convention, which is not a calendar-day count.
This guide covers the syntax, what each basis does, the errors you will run into, and when another function is the better tool. Details are based on Microsoft’s and Google’s documentation as of November 2026.
Syntax
=YEARFRAC(start_date, end_date, [basis])
| Argument | Required? | What it is |
|---|---|---|
start_date | Yes | The first date |
end_date | Yes | The second date |
basis | No | A number from 0 to 4 that picks the day-count method. Leave it out and you get 0 |
According to Microsoft’s YEARFRAC reference, all arguments are truncated to integers. If a date has a time attached, the time is dropped, and a basis of 1.9 is read as 1.
Microsoft describes the function as a way to work out what share of a year’s benefits or obligations falls in a given period. In practice people also use it for prorating, accruals, ages and service length.
The five basis options
The basis argument is where most confusion comes from. Excel and Google Sheets support the same five values:
| Basis | Method | How it counts |
|---|---|---|
| 0 or omitted | US (NASD) 30/360 | 30-day months, 360-day year |
| 1 | Actual/actual | Actual days between the dates, divided by the actual year length |
| 2 | Actual/360 | Actual days, divided by 360 |
| 3 | Actual/365 | Actual days, divided by 365 |
| 4 | European 30/360 | 30-day months and a 360-day year, using European rules for month-end dates |
Some notes from the official docs:
- Basis 1: Microsoft says the year length is the average length of the years the range crosses, wherever the start and end dates fall within those years.
- Basis 0: Microsoft warns that YEARFRAC may return an incorrect result with the US (NASD) 30/360 basis when
start_dateis the last day of February. - Choosing a basis: Google’s Sheets documentation says the function is mostly used in financial settings, where NASD 30/360 is the standard. For non-financial use, Google says option 1 is most likely the right choice.
What difference the basis makes
Microsoft’s example uses 1 January 2012 as the start date and 30 July 2012 as the end date:
- With basis omitted (30/360), the result is 0.58055556.
- With basis 1 (actual/actual), the result is 0.57808219.
The gap is small here, but it grows over longer periods and when amounts are large. For bond or loan calculations, match the day-count convention in the contract. For general business use, pick one basis, write it into the formula explicitly, and stick to it so the numbers in your workbook stay consistent.
How to use YEARFRAC step by step
- Put real dates in two cells, for example A2 (start) and B2 (end). Make sure Excel treats them as dates. A quick check is that they align right by default, or that changing the format to General shows a serial number.
- In C2, enter
=YEARFRAC(A2, B2, 1). Always typing the basis makes the formula easier to read and avoids the 30/360 default surprising someone later. - Format C2 as a number with as many decimals as you need. Wrap it in
ROUND(...)if you want to store a rounded value instead of only displaying one. - To use the fraction, multiply it. For example,
=YEARFRAC(A2, B2, 1) * 12000prorates a 12,000 annual amount over that period.
Entering dates inside the formula
Don’t type dates as text inside the formula. Microsoft recommends using the DATE function, or dates that come from other formulas, because dates entered as text can cause problems. The LibreOffice help page also points out that slashes or dashes typed in a formula can be read as division or subtraction. So write:
=YEARFRAC(DATE(2026,1,1), DATE(2026,11,22), 1)
rather than putting raw 1/1/2026 text in the arguments.
Common errors and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
#VALUE! | A date argument isn’t a valid date, often text that only looks like a date | Convert to a real date with DATE, DATEVALUE or Text to Columns |
#NUM! | Basis is below 0 or above 4 | Use 0, 1, 2, 3 or 4 |
| Result is slightly off from what you expect | Default 30/360 basis in use | Add basis 1 (or the convention you need) |
| Odd result when the start date is 28/29 February | Known issue with the US 30/360 basis | Use a different basis or check the result by hand |
Excel stores dates as serial numbers, with 1 January 1900 as serial 1 by default. That is why a real date can feed straight into YEARFRAC while a text string can’t. If you call the function from VBA through WorksheetFunction.YearFrac, keep in mind that VBA numbers dates differently from the worksheet, where serial 1 is 31 December 1899.
Using YEARFRAC for age and tenure
A widely shared pattern for age is:
=INT(YEARFRAC(birthdate, TODAY()))
It works most of the time, but Exceljet points out that it can sometimes come out a year short. Its example is 30 June 1960 to 30 June 1962 with basis 1, which returns about 1.998 instead of 2, and INT then rounds that down to 1. Exceljet also notes that the default basis counts on a 360-day year, which is another way results drift from a plain calendar count.
So here are the guidelines:
- Whole completed years (age, full years of service): use
=DATEDIF(start, end, "y"). Exceljet and others recommend this for exact completed years. - Fractional years (prorating, accruals, “3.4 years of tenure”): use
YEARFRACwith an explicit basis, usually 1 outside finance. - Financial instruments: use whichever basis the contract or market convention specifies.
Exceljet’s years-between-dates formula covers both approaches if you want to compare them side by side.
YEARFRAC in Google Sheets and other spreadsheets
Google Sheets supports the same function, written as YEARFRAC(start_date, end_date, [day_count_convention]). Per Google’s help page, the third argument is optional and defaults to 0 (US NASD 30/360), the same as Excel. Some third-party tutorials say the Sheets default is actual/actual. That contradicts Google’s own documentation, so trust the official page.
LibreOffice Calc also has YEARFRAC with the same basis codes, which helps if you move workbooks between apps. Basis 1 is the trickiest convention to implement, so if you need exact agreement across tools, test a few known date pairs in each app before relying on the output.
Quick reference
- Fractional years, general use:
=YEARFRAC(A2, B2, 1) - Financial 30/360 (US):
=YEARFRAC(A2, B2)or=YEARFRAC(A2, B2, 0) - Whole years only:
=DATEDIF(A2, B2, "y") - Always feed real dates, not text, and always state the basis so the next person knows which convention you meant.
Free apps worth trying
SponsoredSponsored links. Installing through them can earn us a commission, at no cost to you. Apps are free to download; some offer optional in-app purchases.
Frequently asked questions
What is the default basis in Excel YEARFRAC? +
If you leave the basis argument out, Excel uses 0, the US (NASD) 30/360 method. That treats every month as 30 days and every year as 360 days, so it can differ slightly from a calendar-day count.
Which YEARFRAC basis should I use for ages or employee tenure? +
For non-financial work, basis 1 (actual/actual) is usually the sensible choice, and Google's documentation says the same for Sheets. If you only need whole completed years, DATEDIF(start, end, "y") avoids the rounding edge cases that INT(YEARFRAC()) can hit.
Why does YEARFRAC return #VALUE! or #NUM!? +
#VALUE! means one of the dates is not a valid date, often because it is stored as text. #NUM! means the basis is below 0 or above 4.
Does YEARFRAC work the same way in Google Sheets? +
Yes, the syntax and the five day-count options match. Google calls the third argument day_count_convention, and it also defaults to 0 (US NASD 30/360).
Sources
- YEARFRAC function - Microsoft Support (support.microsoft.com)
- YEARFRAC - Google Docs Editors Help (support.google.com)
- Get age from birthday - Exceljet (exceljet.net)
- Calculate years between dates - Exceljet (exceljet.net)
- YEARFRAC - LibreOffice Help (help.libreoffice.org)