DATEDIF
Description
Returns the number of days, months, or years between two dates, based on the
specified unit. We provide DATEDIF for compatibility but it calculates incorrect
results in some situations. We strongly recommend using WD.DATEDIF for more accurate
results.
Syntax
DATEDIF(
start_date
,
end_date
,
unit
)
- start_date: The starting date for the count. Workday recommends using a cell reference to specify the date instead of entering the date as text, to ensure reliable results.
- end_date: The ending date for the count. Workday recommends using a cell reference to specify the date instead of entering the date as text, to ensure reliable results.
- unit: The 1- or 2-character code specifying the information to include in the result. The value is case-sensitive.CodeReturnsYThe number of complete years in the period.MThe number of complete months in the period.DThe number of days in the period.MDThe difference between the days in start_date and end_date. The function ignores the months and years of the dates.YMThe difference between the months in start_date and end_date. The function ignores the days and years of the dates.YDThe difference between the days of start_date and end_date. The function ignores the years of the dates.
Example
Formula | Result |
|---|---|
=DATEDIF("01-Jan-2015", "10-Jan-2015", "D") | 9 |
=DATEDIF("14-Jul-2016", "01-Dec-2016", "YM") | 5 |