Dates function

DATEDIF

How long between two dates.

Purpose

Measure a gap between two dates in whole years, months or days

Returns

A number, in whatever unit you asked for

Syntax

=DATEDIF(start, end, unit)

ArgumentRequiredWhat goes here
startRequiredThe earlier date, which goes first.
endRequiredThe later date, which goes second.
unitRequiredIn double quotes: "d" for days, "m" for whole months, "y" for whole years.

How to use DATEDIF

DATEDIF takes the earlier date first, then the later one, then a unit in quotation marks: "d" for days, "m" for whole months, "y" for whole years.

It counts completed units and discards the remainder. Two dates a month and twenty-nine days apart are one month apart to DATEDIF.

That is right for anything measured in periods served: months of a prepayment released, years of service, complete months a debt has been outstanding.

The argument order is the reverse of DAYS, which is worth pausing over every time you write one after the other.

Examples

Every result below is worked out by the same evaluator that marks your answers, on the sheet shown here.

Receivables ageing — October.xlsxSheet1
A receivables schedule with its reporting date above the data, the layout a real ageing uses
ABCDE
1Reporting date2026-10-31
2
3InvoiceInvoice dateTerms (days)AmountCustomer
4INV-90012026-07-14301200Calder Utilities
5INV-90022026-08-2930640Brightwell Paper
6INV-90032026-09-03453100Meridian Freight
7INV-90042026-09-3014455Thornbury Print
8INV-90052026-10-12302080Calder Utilities
9INV-90062026-10-2760725Ashgrove Catering
FormulaResult
=DATEDIF(B4,B1,"d")The same number DAYS gives, with the arguments in the other order.109
=DATEDIF(B4,B1,"m")Complete months. The leftover days are dropped rather than rounded.3
=DATEDIF(B4,B1,"y")Nought complete years, because the gap has not reached one.0
=DATEDIF(B8,B1,"m")An invoice from earlier this month is nought complete months old, which is the answer a period count wants and not the answer an ageing wants.0

Notes

  • DATEDIF is the one Excel function with no argument help in the formula bar. It works, it is just undocumented in the interface.
  • It errors if the first date is later than the second, rather than returning a negative.
Practise DATEDIF in Unit 27

A reference tells you what it does. A unit makes you use it.