Skip to content

DateDiff - Built-in Date & Time Function

Purpose

DateDiff returns the interval between two dates.

Syntax

DateDiff(str, date1, date2)

Arguments

Argument Required Description
str Yes One of the following letters, static or as a result of a valid expression
date1 Yes Any valid datetime expression
date2 Yes Any valid datetime expression

Valid interval specifiers for str:

  • D — day
  • H — hour
  • N — minute
  • S — second

Returns

Integer

See also

Example

// returns the number of days between current date and time and the stored
// order date and time
Return DateDiff ('D', now(), {OrderHeader.Order_Date})

Notes

  • When the arguments cannot be converted to the specified type, a runtime error is generated.
  • The order of the two date parameters is important for the result. If date1 is prior to date2, the result will be negative.