SUBTIME()
This page is part of MariaDB's Documentation.
The parent of this page is: Functions for MariaDB Xpand
Topics on this page:
Overview
Subtracts a TIME
from a TIME
or DATETIME
and returns the result.
USAGE
SUBTIME(starting_time, subtracting_time)
Argument Name | Description |
---|---|
| The starting |
| The |
DETAILS
SUBTIME()
is a date-time function that subtracts one time expression from another.
The return value matches the type of the starting_time
argument, which can be either a TIME
or DATETIME
field or string value.
A time value can also contain a count of days in front of the normal hours/minutes/seconds in order to subtract time values greater than a single day. The hours number can also be larger than 24 as a way to express more than one day's worth of time.
The maximum returned time value is 813:59:59.999999
.
A NULL
is returned if any argument is NULL
.
EXAMPLES
SELECT SUBTIME('23:59:59.99', '01:01:01.01') AS result;
+-----------------+
| result |
+-----------------+
| 22:58:58.980000 |
+-----------------+
SELECT SUBTIME('2019-12-30 23:59:59.99', '2 2:2:2') AS result;
+----------------------------+
| result |
+----------------------------+
| 2019-12-28 21:57:57.990000 |
+----------------------------+
SELECT SUBTIME('2 00:00:00', '48:00:00') AS result;
+-----------------+
| result |
+-----------------+
| 00:00:00.000000 |
+-----------------+