Years of service, rounded down (DATEDIF)

Hard Math
Description
Hints 0/4
Solutions 2
–
Test case
1
2
3
Reset
Submit
fx
A
B
C
D
E
F
G
1
2
3
4
5
6
7
8
9
10
Loading interactive spreadsheet...
Preparing grid cells and formula calculation engine
○ Ready Enter formula in highlighted cells, then click Submit.

The problem

Problem statement

HR runs a benefits review and needs each person's completed years of service, not a decimal. Hire dates are in B2 and the review date sits in C2. Fill the Years cell D2 with whole years — someone hired five years and six months ago counts as 5.

Count completed years only — case 2 is one day short of three years and must still show 2, case 3 one day short of ten.

Problem data

Show the sheet as a table (selectable, copyable)
The exercise data, as a table
ABCD
1 EmployeeHire dateReview dateYears
2 Ava Chen2019-03-012024-09-15

Notes

DATEDIF(start, end, "Y") counts how many whole years fit between the two dates, so a partial year is dropped rather than rounded up. Dividing the day difference by 365 looks equivalent until a leap year or a near-boundary date shows up. DATEDIF is a legacy function: it works, but some Excel versions do not autocomplete it.

How to approach

Your answer goes in D2. On submit we re-run your formula against 3 different sets of input, so a hardcoded number will fail — the formula has to follow the cells.

  1. Target cell is D2
  2. The hire date is B2, the review date is C2
  3. DATEDIF takes three arguments: start, end, and a unit — "Y" means whole years
  4. Shape: =DATEDIF(?, ?, "Y")

Official solutions

Show 2 solutions — try it yourself first

Approach 1: DATEDIF with the "Y" unit

=DATEDIF(B2,C2,"Y")

DATEDIF walks the calendar and counts completed anniversaries, so 2019-03-01 to 2024-09-15 is 5 — the extra six months are ignored, not rounded.

Approach 2: whole months divided by 12

=ROUNDDOWN(DATEDIF(B2,C2,"M")/12,0)

Counting months and dividing by 12 gives the same number, and it makes the rounding explicit. Useful when you also need the leftover months for a "5 years 6 months" label.

Function guide

Related practice

FAQ

Why doesn't DATEDIF appear in Excel's function list?

It is a legacy function kept for compatibility with Lotus 1-2-3. It evaluates fine and autocompletes in some versions, but Microsoft never documented it fully — type it by hand if IntelliSense does not offer it.

Why not just use (C2-B2)/365?

Because a year is not always 365 days. Leap years stretch the divisor, and the result is a decimal that you then have to round by hand — 4.98 becomes 5 even when the person has not completed five years. DATEDIF counts anniversaries instead.

What else can DATEDIF return?

"Y" for whole years, "M" for whole months, "D" for days, and the combinations "YM", "MD", "YD" for the remainder after the larger unit. That is how you build a "5 years 6 months" label.