WD.DATEDIF
Description
Returns the amount of time between two dates, based on the specified period and its corresponding unit. We recommend using WD.DATEDIF instead of DATEDIF; we provide DATEDIF for compatibility but it calculates incorrect results in some situations. Note that Worksheets doesn't support submitting non-English values for the arguments.
Syntax
WD.DATEDIF(
start_date
, end_date
, period
, 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.
- period: The number of whole periods betweenstart_dateandend_date. If the period is a grouping of values, such asYMD, the function calculates all the whole periods as segments; you use theunitargument to specify which number (segment) to return. Example: If thestart_dateis January 1, 2010, and theend_dateis February 3, 2020, then the function calculates that Year=10, Month=1 and Day=2. If the unit=Month, the function returns 1.
- Year (Y)
- Month (M)
- Week (W)
- Day (D)
- Hour (H)
- Minute (M)
- Second (Sec or S)
- Milli (Mil or MS)
- YearMonthWeekDayTime (YMWDT): Years, months, weeks, days, hours, minutes, seconds, and milliseconds.
- YearMonthDayTime (YMDT): Years, months, days, hours, minutes, seconds, and milliseconds
- YearMonthDay (YMD): Years, months, and days
- YearWeekDayTime (YMDT): Years, weeks, days, hours, minutes, seconds, and milliseconds
- YearWeekDay (YWD): Years, weeks, and days
- YearDayTime (YDT): Years, days, hours, minutes, seconds, and milliseconds
- YearDay (YD): Years and days
- DayTime (DT): Days, hours, minutes, seconds, and milliseconds
- Time (T): Hours, minutes, seconds, and milliseconds
- unit: The number to return. If theperiodis a single value, such as Day, theunitmust match theperiod. If theperiodis a grouped value, such as YMD, theunitmust match one of the segments in theperiod.
- Year (Y)
- Month (M)
- Week (W)
- Day (D)
- Hour (H)
- Minute (Min)
- Second (S or Sec)
- Milli (or MS or Mil)
Example
The examples are based on this data:
A | B | C | D | |
|---|---|---|---|---|
1 | Start Date | End Date | Period | Unit |
2 | 07/02/2018 05:17:33.636 PM | 03/31/2020 12:00:00.000 AM | Year | Year |
3 | Month | Month | ||
4 | Week | Week | ||
5 | Day | Day | ||
6 | YMD | M |
Here are some example formulas and results:
Formula | Result |
|---|---|
=WD.DATEDIF(A2,B2,C2,D2) | 1 |
=WD.DATEDIF(A2,B2,C3,D3) | 20 |
=WD.DATEDIF(A2,B2,C4,D4) | 91 |
=WD.DATEDIF(A2,B2,C5,D5) | 637 |
=WD.DATEDIF(A2,B2,C6,D6) | 8 |
In a more complex example, you can specify several unit values using a range of cells to calculate the same number of results.

Place the formula =WD.DATEDIF(A2,B2,C2,D2:F2) in cell D3 and submit it as an unconstrained array formula using Ctrl+Alt+Enter (Window) or Option+Alt+Enter (Mac).