DATEDIF
DATUMVERSCHIL in Dutch Excel
Counts the complete years, months or days between two dates, for example the age of an asset or the months a receivable has been open.
Last updated: 13 October 2026
| Row | A | B | C | D | E |
|---|---|---|---|---|---|
| 1 | Asset | Description | Purchase date | Year end | Complete years |
| 2 | FA-0107 | Delivery van | 15 Mar 2021 | 31 Dec 2025 | 44=DATEDIF(C2, D2, "Y")=DATEDIF(C2; D2; "Y") |
| 3 | FA-0108 | Welding machine | 30 Nov 2023 | 31 Dec 2025 | |
| 4 | FA-0109 | Laptops | 10 Feb 2025 | 31 Dec 2025 | |
| 5 | FA-0110 | Forklift | 31 Dec 2019 | 31 Dec 2025 |
Swipe sideways to see all columns
Result: 4
=DATEDIF(C2,D2, "Y")
=DATEDIF(C2;D2; "Y")
What DATEDIF does and when to use it
What it does: it counts the complete years, months or days between two dates, for example the months an invoice has been open.
When to use it: for ages, length of service and ageing in whole months. It is missing from Excel's function list and wizard, but it works in every version. For days only, subtract the dates or use DAYS; for years with decimals, YEARFRAC.
How Excel evaluates it
Excel first checks that start_date is not later than end_date and returns #NUM! if it is. Then it counts by unit:
- "Y": how many anniversaries of start_date fall on or before end_date
- "M": how many monthly steps from start_date fit before end_date
- "D": the difference of the two serial numbers
Partial years and months are dropped, never rounded up.
Watch out: A month counts only when the end date reaches the day number of the start date: from 31 October to 30 November, "M" returns 0.
Mental model
Think of birthdays. DATEDIF with "Y" counts the birthdays that have passed: the day before the next one, you are still the same age.
Terms used on this page: serial number
DATEDIF(start_date,end_date, unit)
DATEDIF(start_date;end_date; unit)
| Argument | Type | Meaning |
|---|---|---|
start_date | Required | The earlier date. |
end_date | Required | The later date. |
unit | Required | The unit as text: "Y", "M" or "D" (Dutch examples: "J", "M", "D"). |
Return value:A whole number of years, months or days, depending on unit
Formulas use commas (,) between arguments, as in English Excel. Formulas use semicolons (;) between arguments, as in Dutch Excel. Formulas use commas (,) between arguments, as in English Excel; Dutch Excel uses semicolons (;).
Worked examples
Beginner
Age of fixed assets in complete years
In the fixed asset register of Veldhuis Installatie BV you want the age of every asset in complete years at the year end of 31 December 2025, to compare with the depreciation period. The register has the purchase date and the year end in two columns.
| Row | A | B | C | D | E | F |
|---|---|---|---|---|---|---|
| 1 | Asset | Description | Purchase date | Year end | Complete years | |
| 2 | FA-0107 | Delivery van | 15 Mar 2021 | 31 Dec 2025 | 44=DATEDIF(C2, D2, "Y")=DATEDIF(C2; D2; "Y") | |
| 3 | FA-0108 | Welding machine | 30 Nov 2023 | 31 Dec 2025 | ||
| 4 | FA-0109 | Laptops | 10 Feb 2025 | 31 Dec 2025 | ||
| 5 | FA-0110 | Forklift | 31 Dec 2019 | 31 Dec 2025 | ||
| 6 |
Swipe sideways to see all columns
Formula in E2
=DATEDIF(C2,D2, "Y")
=DATEDIF(C2;D2; "Y")
Result: 44
Step by step
- DATEDIF has three arguments: start_date is
C2(15 March 2021), end_date isD2(31 December 2025) and unit is the code for years, Y in the English formula and J in the Dutch one. - The start date is not later than the end date, so Excel goes on. It counts the anniversaries of 15 March 2021 that are on or before 31 December 2025: 15 March 2022, 2023, 2024 and 2025. That is 4.
- The next anniversary, 15 March 2026, is after the year end, so it is not counted. The van is 4 complete years old, although at 4 years and 9 months it is close to 5.
- Copied down,
E3returns 2 (30 November 2023, anniversaries in 2024 and 2025),E4returns 0 (the first anniversary, 10 February 2026, is still to come) andE5returns 6, because the sixth anniversary of 31 December 2019 is exactly the year end.
Watch out: Typing DATEDIF in a cell shows no suggestion and no argument tooltip, because the function is not in the list. Type it in full and check that the formula is accepted.
More on this example: why it works
Why it works
DATEDIF does not round. It counts only the anniversaries that have already happened by the end date, and a partial year is dropped. That is the definition of an age, and the reason the answer for the van is 4 and not 5.
Intermediate
Age open invoices in complete months, with a guard for dates after year end
For the ageing of the receivables you need the age of each open invoice in complete months at the balance date of 31 December 2025.
One invoice in the list is dated 5 January 2026. DATEDIF would return #NUM! for it, but that invoice is exactly the cut-off exception you want to follow up, so the sheet should say so in words.
| Row | A | B | C | D | E | F | G | H |
|---|---|---|---|---|---|---|---|---|
| 1 | Invoice no. | Invoice date | Open amount | Age in months | Balance date | 31 Dec 2025 | ||
| 2 | F-25-0731 | 20 Aug 2025 | €12,100.00€ 12.100,00 | 44=IF(B2 > $G$1, "Dated after balance date", DATEDIF(B2, $G$1, "M"))=IF(B2 > $G$1; "Dated after balance date"; DATEDIF(B2; $G$1; "M")) | ||||
| 3 | F-25-0802 | 31 Oct 2025 | €4,235.50€ 4.235,50 | |||||
| 4 | F-25-0690 | 30 Jun 2025 | €8,750.00€ 8.750,00 | |||||
| 5 | F-26-0004 | 5 Jan 2026 | €3,025.00€ 3.025,00 | |||||
| 6 | F-25-0455 | 14 Mar 2025 | €15,640.25€ 15.640,25 | |||||
| 7 |
Swipe sideways to see all columns
Formula in D2
=IF(B2 > $G$1,"Dated after balance date", DATEDIF(B2, $G$1, "M"))
=IF(B2 > $G$1;"Dated after balance date"; DATEDIF(B2; $G$1; "M"))
Result: 44
Step by step
- IF evaluates its test first:
B2>$G$1.B2is 20 August 2025 and$G$1is 31 December 2025, so the test is FALSE and IF takes its third argument. - DATEDIF counts complete months from 20 August 2025 to 31 December 2025. The month steps land on 20 September, 20 October, 20 November and 20 December. The next one, 20 January 2026, is after the balance date. The result is 4.
- The $ signs lock
G1, so every row is tested against the same balance date when you copy the formula down. - In
D5the test is 5 January 2026 > 31 December 2025, which is TRUE. IF returns the text Dated after balance date and DATEDIF is never evaluated, so there is no #NUM!. Without the IF,D5would show #NUM!. - The other rows return 2 (31 October to 31 December), 6 (30 June to 31 December) and 9 (14 March to 31 December).
Watch out: Complete months follow the day number. An invoice of 31 October is 2 months old at 31 December, but at 30 November the same invoice is 0 months old, because November has no 31st.
More on this example: why it works, 1 more pitfall, 1 variation
Why it works
DATEDIF refuses a reversed pair of dates, so the guard has to come before it. IF only evaluates the branch it needs, which is why the failing DATEDIF in the other branch never runs. The unit "M" is the same in English and Dutch Excel.
Watch out for
Complete months follow the day number. An invoice of 31 October is 2 months old at 31 December, but at 30 November the same invoice is 0 months old, because November has no 31st.
A balance date that is not a month end can therefore age month-end invoices one month lower than you expect.
Variations
=IFERROR(DATEDIF(B2,$G$1, "M"), "Dated after balance date")
=IFERROR(DATEDIF(B2;$G$1; "M"); "Dated after balance date")
Shorter, but IFERROR hides every error, including a text date in B2. Prefer the IF test when you want to name the exact cause.
Advanced
Remaining lease term in years and months
For the lease disclosure you need the remaining term of each lease contract at the balance date of 31 December 2025, written as years and months. The contract list has only the end date.
The balance date is the last day of a month, which makes the month count more delicate than it looks.
| Row | A | B | C | D | E | F | G | H |
|---|---|---|---|---|---|---|---|---|
| 1 | Contract | Description | End date | Remaining term | Balance date | 31 Dec 2025 | ||
| 2 | L-01 | Warehouse lease | 15 Jul 2028 | 2 y 6 m=DATEDIF($G$1, C2, "Y") & " y " & (DATEDIF($G$1, C2, "M") - 12 * DATEDIF($G$1, C2, "Y")) & " m"=DATEDIF($G$1; C2; "Y") & " y " & (DATEDIF($G$1; C2; "M") - 12 * DATEDIF($G$1; C2; "Y")) & " m" | ||||
| 3 | L-02 | Office lease | 28 Feb 2027 | |||||
| 4 | L-03 | Company cars | 30 Nov 2026 | |||||
| 5 | L-04 | Copier | 31 Dec 2030 | |||||
| 6 | L-05 | Parking spaces | 31 Jan 2026 | |||||
| 7 |
Swipe sideways to see all columns
Formula in D2
=DATEDIF($G$1,C2, "Y") & " y " & (DATEDIF($G$1, C2, "M") - 12 * DATEDIF($G$1, C2, "Y")) & " m"
=DATEDIF($G$1;C2; "Y") & " y " & (DATEDIF($G$1; C2; "M") - 12 * DATEDIF($G$1; C2; "Y")) & " m"
Result: 2 y 6 m
Step by step
- Excel evaluates the DATEDIF calls from left to right. The first counts complete years from 31 December 2025 to 15 July 2028. The anniversaries are 31 December 2026 and 31 December 2027; 31 December 2028 is after the end date. The result is 2.
- The second call, with "M", counts complete months. From December 2025 to July 2028 is 31 calendar months, but the end date has day number 15 and the start date 31, so the last step is not complete. The result is 30.
- The third call is the year count again: 2. The months that remain after removing the whole years are 30 - 12 * 2 = 30 - 24 = 6.
- The & operator joins the pieces: 2, the text for years, 6 and the text for months.
D2shows 2 y 6 m (Dutch: 2 jr 6 mnd). - Copied down,
D3gives 1 y 1 m (end date 28 February 2027 has day 28, below 31, so 13 months, not 14),D4gives 0 y 10 m,D5gives 5 y 0 m andD6gives 0 y 1 m.
Watch out: A balance date at a month end combined with a short end month gives a count that is one month lower than the calendar suggests: L-03 ends on 30 November 2026 and shows 10 months, not 11. The result is consistent with the rule, but it surprises a reader who counts months on the calendar. Document the rule in your working paper.
More on this example: why it works, 1 more pitfall, 2 variations
Why it works
Total months minus 12 times the years leaves the months beyond the last whole year, and both counts use the same rule for complete units, so they cannot contradict each other. The unit "YM" would give that remainder directly, but its Dutch code is not documented, while "Y" and "M" are.
More to watch out for
- A contract whose end date lies before the balance date makes DATEDIF return #NUM!. An expired contract in the list breaks the whole row, so filter those out or add the IF guard from the Intermediate example.
Variations
=DATEDIF($G$1,C2, "M")
=DATEDIF($G$1;C2; "M")
Only the total number of months, 30 for L-01. Use it when the disclosure asks for a term in months.
=YEARFRAC($G$1,C2)
=YEARFRAC($G$1;C2)
The term as a decimal number of years, about 2.54 for L-01, based on a 30/360 year. Choose it when you need to multiply the term by an amount.
MasterExcel 2021 or later (This example needs Excel 2021 or later)
Age in months and remaining days, without the "MD" unit
The ageing report for a debtors review at 15 January 2026 must show how old each invoice is in complete months plus the remaining days, for example 4 months and 15 days.
The usual route is DATEDIF twice, once with "M" and once with "MD", but Microsoft warns that "MD" can return negative or wrong numbers. You need a version you can defend in a review.
| Row | A | B | C | D | E | F | G | H |
|---|---|---|---|---|---|---|---|---|
| 1 | Invoice no. | Invoice date | Open amount | Age | Ageing date | 15 Jan 2026 | ||
| 2 | F-25-0844 | 31 Aug 2025 | €18,400.00€ 18.400,00 | 4 m 15 d=LET( since, B2, until, $G$1, whole, DATEDIF(since, until, "M"), rest, until - EDATE(since, whole), whole & " m " & rest & " d" )=LET( since; B2; until; $G$1; whole; DATEDIF(since; until; "M"); rest; until - EDATE(since; whole); whole & " m " & rest & " d" ) | ||||
| 3 | F-25-0912 | 20 Nov 2025 | €6,300.00€ 6.300,00 | |||||
| 4 | F-25-0951 | 15 Dec 2025 | €2,750.00€ 2.750,00 | |||||
| 5 | F-25-0377 | 28 Feb 2025 | €9,100.00€ 9.100,00 | |||||
| 6 | F-25-0502 | 31 May 2025 | €12,500.00€ 12.500,00 | |||||
| 7 |
Swipe sideways to see all columns
Formula in D2
=LET( since,B2, until, $G$1, whole, DATEDIF(since, until, "M"), rest, until - EDATE(since, whole), whole & " m " & rest & " d" )
=LET( since;B2; until; $G$1; whole; DATEDIF(since; until; "M"); rest; until - EDATE(since; whole); whole & " m " & rest & " d" )
Result: 4 m 15 d
Step by step
- LET reads its arguments in pairs: a name, then a value. since becomes
B2, 31 August 2025, and until becomes$G$1, 15 January 2026. - whole is DATEDIF(since, until, "M"). From August 2025 to January 2026 is 5 calendar months, but the end date has day number 15 and the start date 31, so the fifth step is not complete. whole is 4.
- rest is until - EDATE(since, whole). EDATE moves 31 August 2025 forward by 4 months and lands on 31 December 2025. The subtraction is 15 January 2026 - 31 December 2025 = 15 days.
- The last argument of LET joins the pieces: 4, the text for months, 15 and the text for days.
D2shows 4 m 15 d (Dutch: 4 mnd 15 d). - Copied down,
D3gives 1 m 26 d (20 November to 20 December is one month, then 26 days to 15 January),D4gives 1 m 0 d,D5gives 10 m 18 d andD6gives 7 m 15 d.
Watch out: The mirror-image mistake: DATEDIF(since, until, "MD") looks right on most rows and only goes wrong around month ends, so a test on a few rows passes. Check month-end invoices such as F-25-0844 specifically.
More on this example: why it works, 2 more pitfalls, 2 variations
Why it works
The remaining days are measured from the exact date that the whole months reach, so months and days always add up to the real interval. That is what "MD" is supposed to do but cannot do reliably.
Microsoft's own workaround subtracts the first day of the end month instead, which gives 14 here, a different quantity (days into January, not days since the last month step). Do not use this construction when you only need days (subtract the dates) or a decimal number of years (YEARFRAC): those are shorter and cannot misread a month end.
More to watch out for
- If an invoice date is later than the ageing date, DATEDIF returns #NUM! and the whole LET fails. Put the guard from the Intermediate example around it when the list may contain such invoices.
- The result is text. It cannot be summed or sorted by age, so keep the numeric month count in a helper column when the report needs bands.
Variations
=DATEDIF(B2,$G$1, "M")
=DATEDIF(B2;$G$1; "M")
Only the complete months, 4 for F-25-0844, when the report bands the age in months.
=$G$1 - B2
=$G$1 - B2
The age in plain days, 137 for F-25-0844. Prefer it when a day count is enough: it cannot fail on a month end.
Common mistakes
| Symptom | Cause | Fix |
|---|---|---|
| #NUM! with the dates in reverse order | The result is #NUM! because start_date is later than end_date, for example when the invoice date comes after the reporting date. | Test the order first with IF(start > end, ...), as the Intermediate example does. A reversed pair is often a finding in itself, such as a cut-off error. |
| Error in one language of Excel only | The formula works in one language of Excel and gives an error in the other. The unit is text, and Microsoft's own pages use "Y" in English and "J" in the Dutch examples. | Test the code in your own Excel and use the one that works there: Microsoft's English page uses "Y", its Dutch examples use "J". This site shows the code for the page language in every example. |
| Wrong or negative days with "MD" | The unit "MD" returns a negative number, 0 or a wrong number of days. | Avoid "MD", as Microsoft does. Calculate the remaining days as the end date minus the date one whole month step after the start, as the Master example does with EDATE. |
| A full month is not counted | A month looks complete but is not counted, because the end date has a lower day number than the start date. | For month-end dates, test one day on each side of the boundary before you rely on the result. |