Skip to main content

DateDiff

The DateDiff function returns a number representing the difference between two dates.

Prototype

  DateDiff(Date1; Date2; Unit)

Arguments

  Date1          Date         By value

A valid Date. The argument can be a literal, the result of an expression or a variable (Studio only) that
evaluates a Date.

Date2 Date By value

A valid Date. The argument can be a literal, the result of an expression or a variable (Studio only) that
evaluates a Date.

Unit String By value`

A valid String, containing the selected Unit. Argument can be a literal, the result of an expression or a variable
(Studio only) that evaluates a String. Valid Units are:

Returns

Number

A number representing the difference between the two dates.

Exception

Undefined

Undefined is returned if:

- Date1 or Date2 is Underfined or is not a Date
- Format is Undefined, is not a String, or does not contain a valid Unit
UnitDescription
MsMilliseconds
SSeconds
MMinutes
HHours
DDays

Example

    DateDiff( Date(05022020 ; 'ddmmyyyy') ; Date(05012020; 'ddmmyyyy'); 'd')

This will return [1] (i.e., the number of days).