ADDDATE()
This page is part of MariaDB's Documentation.
The parent of this page is: Functions for MariaDB Xpand
Topics on this page:
Overview
Works as a synonym for DATE_INTERVAL
expression.
USAGE
ADDDATE(date, INTERVAL number unit)
ADDDATE(date, days)
Argument Name | Description |
---|---|
| The starting date |
| The number of units to add, where |
| 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
.
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 |
+----------------------------+