ADDDATE()

Overview

Works as a synonym for DATE_ADD() with one exception: the second argument can be a numeric count of days instead of an INTERVAL expression.

USAGE

ADDDATE(date, INTERVAL number unit)
ADDDATE(date, days)

Argument Name

Description

date

The starting date

INTERVAL number unit

The number of units to add, where unit is a date or time unit

days

The number of days to add

DETAILS

ADDDATE() is a date-time function that adds an interval of time to a date.

The second argument can be either an interval expression or a numeric value that expresses a count of days. Thus, a second argument of 5 is equivalent to INTERVAL 5 DAY.

It is recommended that you CAST a string argument to a DATE or DATETIME type to ensure you get the return value you expect.

A NULL is returned if either argument is NULL.

SYNONYMS

SCHEMA

PARAMETERS

SKYSQL

PRIVILEGES

EXAMPLES

SELECT ADDDATE(CAST('1999-12-01' AS DATE), INTERVAL 31 DAY) AS result1,
       ADDDATE(CAST('1999-04-01' AS DATE), INTERVAL 2 YEAR) + 0 AS result2;
+------------+----------+
| result1    | result2  |
+------------+----------+
| 2000-01-01 | 20010401 |
+------------+----------+
SELECT ADDDATE(CAST('2020-01-02' AS DATETIME), 31) AS result;
+----------------------------+
| result                     |
+----------------------------+
| 2020-02-02 00:00:00.000000 |
+----------------------------+

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