Calculate Years Between Dates
Measure elapsed time as fractional or completed years with YEARFRAC and INT, while keeping the governing day-count basis visible, reproducible, and distinct from simple rounding.
| Calculate Years Between Dates | ||||||||
| YEARFRAC returns elapsed years as a decimal; INT keeps completed whole years. | ||||||||
| Function review, self-contained examples | ||||||||
| Scenario | Start date | End date | Basis | YEARFRAC syntax | Fractional years | INT syntax | Whole years | |
| Exact year | Jan 1, 2024 | Jan 1, 2025 | 1 | =YEARFRAC(B12,C12,D12) | 1.00 | =INT(YEARFRAC(B12,C12,D12)) | 1 | |
| Half year | Jan 1, 2019 | Jul 1, 2019 | 1 | =YEARFRAC(B13,C13,D13) | 0.50 | =INT(YEARFRAC(B13,C13,D13)) | 0 | |
| Leap-year interval | Feb 29, 2024 | Feb 28, 2025 | 1 | =YEARFRAC(B14,C14,D14) | 1.00 | =INT(YEARFRAC(B14,C14,D14)) | 0 | |
| Multi-year | Mar 15, 2020 | Sep 15, 2026 | 1 | =YEARFRAC(B15,C15,D15) | 6.50 | =INT(YEARFRAC(B15,C15,D15)) | 6 | |
| Same day | Aug 21, 2026 | Aug 21, 2026 | 1 | =YEARFRAC(B16,C16,D16) | 0.00 | =INT(YEARFRAC(B16,C16,D16)) | 0 | |
| Reliability checks | ||||||||
| Exact-year example equals 1.00 | OK | |||||||
| Same-day example equals 0.00 | OK | |||||||
Overview
Return elapsed time between two valid dates as either a fractional number of years or completed whole years. YEARFRAC applies an explicit day-count basis; INT removes the remaining fraction when the business rule counts only completed years.
When to use it
Use it for interest or fee accruals, contract-duration analysis, service periods, vesting, and depreciation calculations where elapsed years are needed. The chosen basis must match the governing convention, especially for financial calculations.
When not to use it
Use DATEDIF with unit "Y" when only completed calendar years are required and no day-count convention needs to be shown. Use workday calculations for business-day duration. Do not use YEARFRAC as a substitute for a detailed period schedule when accrual rules change over time.
Problem
Dividing elapsed days by 365 ignores leap years and contractual day-count conventions. Rounding a fractional result also does not mean the same thing as counting completed years: 6.99 years rounds to 7 but contains only six fully completed years.
Inputs
Input | Location | Sample |
|---|---|---|
Start date | | 15-Mar-2020 |
End date | | 15-Sep-2026 |
YEARFRAC basis | | 1 |
Source data
The calculation uses two scalar Excel dates and a basis code from 0 through 4. Basis 1 uses actual days and actual year lengths; the other codes represent US 30/360, actual/360, actual/365, and European 30/360 conventions. The workbook’s comparison table evaluates the same dates under all five codes.
Calculations
- Confirm the start and end are valid Excel dates.
- Select the day-count basis required by the calculation.
- Use YEARFRAC to calculate elapsed fractional years.
- Apply INT to that same result only when completed whole years are required.
- Compare bases when the convention materially affects the result.
Outputs
For the sample, basis 1 produces an underlying YEARFRAC result of about 6.5018, displayed as 6.50 years. INT returns 6 completed years. The five-basis comparison ranges from approximately 6.5000 to 6.5972, demonstrating that basis is part of the result’s meaning.
Formula map
Fractional years
=YEARFRAC(B11,B12,B13)
Completed years
=INT(YEARFRAC(B11,B12,B13))
Both formulas return one number. Formatting can control displayed decimals but does not change the stored fractional result.
Model checks
The workbook confirms that the primary fractional result displays as 6.50, the completed-year result equals 6, and the start date does not exceed the end date. Passing tests return OK.
Edge cases
- Identical start and end dates return zero.
- Basis 1 reflects leap-year day counts.
- Reversed dates return a negative interval rather than automatically rejecting the input.
- Different valid bases can produce different answers for the same dates.
- Rounding and truncating diverge near a completed-year boundary.
Common errors
- Dividing days by 365: this embeds an undocumented convention and mishandles some intervals. Use YEARFRAC with the selected basis.
- Rounding completed years: this can count a year before it is complete. Use INT for the workbook’s completed-year rule.
- Leaving the basis unexplained: readers cannot interpret or reproduce the result. Store and label the basis as an input.
Example
From 15-Mar-2020 to 15-Sep-2026 with basis 1, YEARFRAC returns about 6.5018. Displaying two decimals gives 6.50, while INT returns 6 because only six full years have elapsed. The basis comparison independently shows that convention choices can alter the decimal result.
Example workbook
Replace the cream inputs in Combined Example!B11:B13. Fractional and completed-year outputs appear in H12:H13, with the five-basis comparison and checks nearby. Formula Review covers exact-year, half-year, leap-year, multi-year, and same-day intervals.
Key takeaway
Choose and disclose the day-count basis before calculating elapsed years, and use INT—not display rounding—when the requirement is specifically completed whole years.