DATEDIFFERENCE function
This function is intended to retrieve the difference between two dates.
The first option is the deducted date, DATE type expression;
The second option is the source date, DATE type expression;
The third option is difference type, one of: SECOND, MINUTE, HOUR, DAY, MONTH, QUARTER, YEAR.
Examples:
SELECT DATEDIFFERENCE(DATETIME(2002, 10, 12, 10, 15, 34), DATETIME(2002, 10, 14, 9, 18, 06), DAY)
Result:
Field1
2
SELECT DATEDIFFERENCE(DATETIME(2002, 10, 12), (DATETIME(2002, 11, 03), MONTH)
Result:
Field1
1
Caution! The function calculates calendar difference between two dates so it cannot be used where you need to calculate the number of bank or working days between two dates.
See also: Query Language Functions