SQL DATE_ADD Function: Syntax & Examples

The DATE_ADD function in SQL is used to add or subtract a specified time interval from a given date. Its syntax is as follows:

DATE_ADD(date, INTERVAL value unit)

In this case, date is the date to which a time interval will be added, value is the amount of time to be added or subtracted, and unit is the unit of time such as YEAR, MONTH, DAY, HOUR, MINUTE, SECOND, etc.

For example, you can use the DATE_ADD function to add one month to the current date.

SELECT DATE_ADD(NOW(), INTERVAL 1 MONTH);

This will return the result of adding one month to the current date. The DATE_ADD function can be used for performing date calculations on date fields, making it convenient for date calculations.

bannerAds