HOURS_DIFF
Descriptionβ
Calculates the difference in hours between the start time and the end time.
Syntaxβ
HOURS_DIFF(<end_date>, <start_date>)
Parametersβ
Parameter | Description |
---|---|
<end_date> | The end time, which can be of type DATETIME or DATE |
<start_date> | The start time, which can be of type DATETIME or DATE |
Return Valueβ
Returns an INT type representing the number of hours between the start time and the end time.
Exampleβ
SELECT HOURS_DIFF('2020-12-25 22:00:00', '2020-12-25 21:00:00');
+--------------------------------------------------------------------------------------------------------+
| hours_diff(cast('2020-12-25 22:00:00' as DATETIMEV2(0)), cast('2020-12-25 21:00:00' as DATETIMEV2(0))) |
+--------------------------------------------------------------------------------------------------------+
| 1 |
+--------------------------------------------------------------------------------------------------------+