TIMESTAMPADD()

Overview

Adds the given number of units to the DATE or DATETIME argument and returns the result.

USAGE

TIMESTAMPADD(unit, count, timestamp)

Argument Name

Description

unit

The unit name keyword (not a string)

count

The number of units to add

timestamp

The DATE or DATETIME value

DETAILS

TIMESTAMPADD() is a date-time function that returns the resulting timestamp from adding the interval given as an integer in the second argument in unit given in the first argument to the date, or datetime in the third argument.

The return value is a DATETIME string formatted as either YYYY-MM-DD or YYYY-MM-DD hh:mm:ss depending on the data type of the input timestamp and the units being added.

A NULL is returned if any argument is NULL.

SYNONYMS

SCHEMA

PARAMETERS

SKYSQL

PRIVILEGES

EXAMPLES

SELECT TIMESTAMPADD(MINUTE, 1, '2020-01-02');
+---------------------------------------+
| TIMESTAMPADD(MINUTE, 1, '2020-01-02') |
+---------------------------------------+
| 2020-01-02 00:01:00                   |
+---------------------------------------+
SELECT TIMESTAMPADD(WEEK, 2, '2020-01-02');
+-------------------------------------+
| TIMESTAMPADD(WEEK, 2, '2020-01-02') |
+-------------------------------------+
| 2020-01-16 00:00:00                 |
+-------------------------------------+
SELECT TIMESTAMPADD(MONTH, 3, '2020-01-02 00:00:00');
+-----------------------------------------------+
| TIMESTAMPADD(MONTH, 3, '2020-01-02 00:00:00') |
+-----------------------------------------------+
| 2020-04-02 00:00:00                           |
+-----------------------------------------------+
SELECT TIMESTAMPADD(YEAR, 1, '2019-01-02');
+-------------------------------------+
| TIMESTAMPADD(YEAR, 1, '2019-01-02') |
+-------------------------------------+
| 2020-01-02 00:00:00                 |
+-------------------------------------+

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