Skip to main content
Workday User Guide
Last Updated: 2023-06-23
WD.DATEDIF

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 between
    start_date
    and
    end_date
    . If the period is a grouping of values, such as
    YMD
    , the function calculates all the whole periods as segments; you use the
    unit
    argument to specify which number (segment) to return. Example: If the
    start_date
    is January 1, 2010, and the
    end_date
    is 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 the
    period
    is a single value, such as Day, the
    unit
    must match the
    period
    . If the
    period
    is a grouped value, such as YMD, the
    unit
    must match one of the segments in the
    period
    .
    • 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.
WD.DATEDIF example using range for Unit argument
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).