Syntax
=DATEDIF(start_date, end_date, unit)Arguments
| Argument | Required | Description |
|---|---|---|
start_date | Required | The earlier date |
end_date | Required | The later date |
unit | Required | "Y", "M", "D", "MD", "YM" or "YD" |
How to use DATEDIF
DATEDIF takes 3 required arguments. Type =DATEDIF( in a cell and SheetsBat shows the arguments as you go. Optional arguments are shown in square brackets; leave them out to use their default.
Examples
Each result below was calculated by the SheetsBat formula engine.
=DATEDIF(DATE(2001,1,1), DATE(2003,1,1), "Y")Result =DATEDIF(DATE(2001,6,1), DATE(2002,8,15), "D")Result =DATEDIF(DATE(2001,6,1), DATE(2002,8,15), "YD")Result Related date and time functions
- DATEBuilds a date from a year, a month and a day; months and days past the end roll over.
- DATEVALUEConverts a date written as text into a date serial number.
- DAYReturns the day of the month (1 to 31) of a date.
- DAYSReturns the number of days between two dates.
- DAYS360Returns the days between two dates on a calendar of twelve 30 day months.
- EDATEReturns the date a number of months before or after a date, on the same day of the month where possible.
- EOMONTHReturns the last day of the month a number of months before or after a date.
- HOURReturns the hour (0 to 23) of a time.
- ISOWEEKNUMReturns the ISO week number of the year (weeks start on Monday, week 1 contains the first Thursday).