Skip to main content
Planview Customer Success Center

DateDiff Function

DateDiff (dateTime1 as DateTime, dateTime2 as DateTime, interval as String) as Numeric

Category: Date
Description: Returns the intervals between two dates in number. The 'interval' parameter is a string that should contain one of the following: “y” (for years), “m” (for months), "d" (for days) or "w" (for weeks)
Supported Context: FormulaField And BusinessRules
Parameters:  
dateTime1 as DateTime Represents the first date value as a date or reference to a field that will return a date value
dateTime2 as DateTime Represents the second date value as a date or reference to a field that will return a date value
interval as String Represents the desired interval value between the two dates specified in the "dateTime1" and "dateTime2" parameters, must be equal to either "d", "w", "m", or "y" corresponding to day, week, month, or year
Returned value as Numeric Returns a duration value equal to the difference between the two dates indicated in the "dateTime1" and "dateTime2" parameters using the duration type indicated in the "interval" parameter
Example #1

Create a numeric custom field that will ALWAYS define the length of a project in regular calendar weeks (rather than AdaptiveWork's calendar weeks that might be based on personal calendars). Set the formula to be:

DateDiff($DueDate,$StartDate,"w")

Another example that will get the delay of the due date of a work item, so if a work item has been moved by 7 days will return 7: DateDiff($DueDate, GetPreviousValue($DueDate),"d")

Tips Use the DateSubtract() function to return a duration field type that will take into consideration your AdaptiveWork calendar settings
Related Functions

DateSubtract()

Additional Links

checkbox custom field