ADD_TIME_INTERVAL()

Overview

Returns a TIME or DATETIME value that has count time units added.

USAGE

ADD_TIME_INTERVAL(timestamp, count, unit_string)

Argument Name

Description

timestamp

The starting TIME or DATETIME

count

The number of units to add

unit_string

A string specifying a unit a time, such as 'hour' or 'minute'

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.uuuuuu format.

  • In numeric context, the return value is in the hhmmss.uuuuuu format.

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:ss format. 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').

SYNONYMS

SCHEMA

PARAMETERS

SKYSQL

PRIVILEGES

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 |
+---------------------+

ERROR HANDLING

FEATURE INTERACTION

RESPONSES

DIAGNOSIS

ISO 9075:2016

CHANGE HISTORY

Release Series

History

23.09

  • Present starting in MariaDB Xpand 23.09.1.

6.1

  • Present starting in MariaDB Xpand 6.1.0.

6.0

  • Present starting in MariaDB Xpand 6.0.3.

5.3

  • Present starting in MariaDB Xpand 5.3.13.

Release Series

History

6.0

  • Present starting in MariaDB Xpand 6.0.3.

5.3

  • Present starting in MariaDB Xpand 5.3.13.

Release Series

History

6.1

  • Present starting in MariaDB Xpand 6.1.0.

EXTERNAL REFERENCES