MySQL ADDDATE or DATE_ADD

This weekend I needed a couple of MySQL query items that were out of the ordinary, so I thought I would write about them.

ADDDATE or DATE_ADD both work the same, but came in very handy. I was struggling with an application where I need to have the date 42 days from now. PHP doesn’t really have anything that is easy to use, and after a few tries I decided to turn to MySQL. Below is what MySQL.com has to say on these:

When invoked with the INTERVAL form of the second argument, ADDDATE() is a synonym for DATE_ADD(). The related function SUBDATE() is a synonym for DATE_SUB(). For information on the INTERVAL unit argument, see the discussion for DATE_ADD().

SELECT DATE_ADD('1998-01-02', INTERVAL 42 DAY);
        -> '1998-02-02'
SELECT ADDDATE('1998-01-02', INTERVAL 42 DAY);
        -> '1998-02-02'