Skip to content

SUBTIME

  • time: This is a valid time or datetime expression from which the desired time interval will be subtracted. It could be a date, time, datetime or a string formatted as an SQL date, time, or datetime.
  • expr: This parameter signifies the time interval that will be subtracted from the original time. This could either be represented in terms of a string that specifies time (like ‘02
SELECT SUBTIME('2022-12-31 12:00:00', '3:0:0') AS NewTime;
+---------------------+
| NewTime |
+---------------------+
| 2022-12-31 09:00:00 |
+---------------------+

The SUBTIME() function subtracts a time value from a date or datetime. In the above code, it subtracts ‘3:0:0’ (3 hours) from ‘2022-12-31 12:00:00’ to return a new datetime ‘2022-12-31 09:00:00’.