Calculate the difference between two dates in Excel


One of Excel's handiest worksheet functions ù Datedif ù is undocumented. Datedif returns the difference between two dates, expressed in years, months, or days. You might use the Datedif function to calculate how many months the payment on an invoice is overdue or to count down the number of years, months, and days until the millennium.

Excel's Datedif function is identical to Lotus 1-2-3's @Datedif function and takes three arguments. Its syntax is:

=datedif(start_date,end_date,units)

where start_date is a date or a reference to a date, end_date is a date or a reference to a date, and units is a one- or two-digit string (in double quotes) specifying the units for the difference between the two dates.

UNITS ARGUMENT

Unit symbol

Returns the number ofà

"y"

full years in the period

"m"

full months in the period

"d"

full days in the period

"md"

full days in excess of the last full month

"ym"

full months in excess of the last full year

"yd"

full days in excess of the last full year

Caption: Excel's Datedif function calculates the difference between dates any way you like

û John Walkenbach


Category:spreadsheet
Issue: November 1998

These Web pages are produced by Australian PC World © 1998 IDG Communications