ADD_TIME_INTERVAL()
This page is part of MariaDB's Documentation.
The parent of this page is: Functions for MariaDB Xpand
Topics on this page:
Overview
Returns a TIME or DATETIME value that has count time units added.
USAGE
ADD_TIME_INTERVAL(timestamp, count, unit_string)
Argument Name | Description |
|---|---|
| The starting |
| The number of units to add |
| A string specifying a unit a time, such as |
DETAILS
ADD_TIME_INTERVAL() is a date-time function that returns a timestamp with count units added to it.
When given a TIME value:
In string context, the return value is in the
hh:mm:ss.uuuuuuformat.In numeric context, the return value is in the
hhmmss.uuuuuuformat.
When given a DATETIME value (including passing in a string literal):
In string context, the return value is in the
YYYY-MM-DD hh:mm:ssformat. If fractional seconds were specified, a decimal point and the fractional digits are appended.
In numeric context, the return value is currently just the year number.
A NULL is returned if any argument is NULL or if the unit value is not valid (e.g., if you specified 'hours' instead of 'hour').
EXAMPLES
SELECT ADD_TIME_INTERVAL(CAST('10:34:56' AS TIME), 2, 'hour') AS result;
+-----------------+
| result |
+-----------------+
| 12:34:56.000000 |
+-----------------+
SELECT ADD_TIME_INTERVAL('2020-02-28 10:34:56', 26, 'hour') AS result;
+---------------------+
| result |
+---------------------+
| 2020-02-29 12:34:56 |
+---------------------+
