VeloDB Cloud
SQL Manual
Functions
date-time-functions
hours_sub

hours_sub

Description

Syntax:

DATETIME HOURS_SUB(DATETIME date, INT hours)

This function subtracts the specified number of hours from the given date.

date can be of DATE or DATETIME type, and the returned result is of DATETIME type.

Example

mysql> select hours_sub("2020-02-02 02:02:02", 1);
+-------------------------------------+
| hours_sub('2020-02-02 02:02:02', 1) |
+-------------------------------------+
| 2020-02-02 01:02:02                 |
+-------------------------------------+

Keywords

HOURS_SUB