Search code examples
mysqldatemysql-workbench

Add days to date without using adddate


Add a integer number of days to a date in MySQL without using adddate.

Obviously the following code does the job:

adddate('2024-01-01',100)

My failure attempt is:

'2024-01-01' + 100

Does anyone know an alternative way of adding days to date in MySQL?


Solution

  • mysql> select '2024-01-01' + interval 100 day as date;
    +------------+
    | date       |
    +------------+
    | 2024-04-10 |
    +------------+
    

    Read more about this type of expression here: https://dev.mysql.com/doc/refman/8.0/en/expressions.html#temporal-intervals