Skip to main content

HOURS_SUB

Description​

Returns a new datetime value that is the result of subtracting a specified number of hours from the input datetime.

Syntax​

HOURS_SUB(<date>, <hours>)

Parameters​

ParameterDescription
<date>The input datetime value, which can be of type DATETIME or DATE
<hours>The number of hours to subtract, of type INT

Return Value​

Returns a value of type DATETIME, representing the time value after subtracting the specified number of hours from the input datetime.

Example​

SELECT HOURS_SUB('2020-02-02 02:02:02', 1);
+------------------------------------------------------------+
| hours_sub(cast('2020-02-02 02:02:02' as DATETIMEV2(0)), 1) |
+------------------------------------------------------------+
| 2020-02-02 01:02:02 |
+------------------------------------------------------------+