Calculates the time difference between two dates.

See Sigma's Common Date Functions and Use Cases lab for more information about date functions, including use cases and exercises.

Usage

DateDiff(unit, start, end)

unit (required) Unit to use for the difference; this can be specified with “year”, "quarter", “month”, “week”, “day”, “hour”, “minute”, or “second”.

start (required) The starting date.

end (required) The ending date.

The result is rounded to a whole number. Also, if end is before start, the result will be negative.

Example

DateDiff(“day”, [Invoice Date], Today())
  • The time, in days, between the current UTC date and the Invoice Date.
DateDiff("year", [Invoice Date], Date("2018-01-01")) = 8
  • The time, in years, from [Invoice Date] and January 1, 2018.
DateDiff("hour", [Ticket Date], Now()) = 103
  • The time, in hours, from the Ticket Date to the current UTC date and time.

Was this page helpful?
Yes No