DateDiff
The DateDiff function calculates the time difference between two dates.
For more information (including use case exercises) about date functions, see the Common Date Functions and Use Cases QuickStart.
Syntax
DateDiff(unit, start, end)
Function arguments:
- unit (required) - unit to measure for the difference (i.e., year, quarter, month, week, day, hour, minute, or second)
- start (required) - the starting date
- end (required) - the ending date
The result is rounded to the nearest integer. If the ending date precedes the starting date, the output is a negative integer.
Examples
DateDiff(“day”, [Invoice Date], Today())
- Returns the number of days between the date in the Invoice Date column and the current UTC date.
DateDiff("year", [Invoice Date], Date("2018-01-01")) = 8
- Returns the number of years between the date in the Invoice Date column and January 1, 2018.
DateDiff("hour", [Ticket Date], Now()) = 103
- Returns the number of hours between the date and time in the Ticket Date column and the current UTC date and time.