DATEDIFF
Description
DATEDIFF computes the difference between two dates in the specified time unit.
Supported input column types: DATE
Output column type: FLOAT
Syntax
DATEDIFF ( time_unit, table.date_column1, table.date_column2 )
time_unit: ms | ss | mi | hh | dd | mm | yy
ms: Calculate the difference between the given dates in milliseconds (equals MILLIS_BETWEEN)
ss: Calculate the difference between the given dates in seconds (equals SECONDS_BETWEEN)
mi: Calculate the difference between the given dates in minutes (equals MINUTES_BETWEEN)
hh: Calculate the difference between the given dates in hours (equals HOURS_BETWEEN)
dd: Calculate the difference between the given dates in days (equals DAYS_BETWEEN)
mm: Calculate the difference between the given dates in months (equals MONTHS_BETWEEN)
yy: Calculate the difference between the given dates in years (equals YEARS_BETWEEN)
NULL handling
If any parameter is NULL, the result is NULL as well.
Examples
[1] Calculate the difference between dates of two rows in milliseconds (equals MILLIS_BETWEEN): | |||||||||||||
| |||||||||||||
|
[2] Calculate the difference between dates of two rows in seconds (equals SECONDS_BETWEEN): | |||||||||||||
| |||||||||||||
|
[3] Calculate the difference between dates of two rows in minutes (equals MINUTES_BETWEEN): | |||||||||||||
| |||||||||||||
|
[4] Calculate the difference between dates of two rows in hours (equals HOURS_BETWEEN): | |||||||||||||
| |||||||||||||
|
[5] Calculate the difference between dates of five rows in days (equals DAYS_BETWEEN): | ||||||||||||||||||||||
| ||||||||||||||||||||||
|
[6] Calculate the difference between dates of five rows in months (equals MONTHS_BETWEEN): | ||||||||||||||||||||||
| ||||||||||||||||||||||
|
[7] Calculate the difference between dates of five rows in years (equals YEARS_BETWEEN): | ||||||||||||||||||||||
| ||||||||||||||||||||||
|