Add one year to a given date and return the resulting date.
SELECT DATEADD(year, 1, ‘2017/08/25’) AS DateAdd; |
The DATEADD() function adds a specified time or date interval to a given date and returns the resulting date.
DATEADD(interval, number, date) |
Parameter |
Description |
interval |
Required: Specify the time or date interval to add, using one of the following values:
|
number |
Required: Specify the number of intervals to add to the date. Use positive values to calculate dates in the future and negative values for dates in the past. |
date |
Required: Specify the date that will be modified by adding the specified interval. |
Works in: |
SQL Server (beginning from 2008), Azure SQL Database, Azure SQL Data Warehouse, and Parallel Data Warehouse |
Add two months to a given date and return the resulting date.
SELECT DATEADD(month, 2, ‘2017/08/25’) AS DateAdd; |
Subtract two months from a specified date and return the resulting date.
SELECT DATEADD(month, –2, ‘2017/08/25’) AS DateAdd; |
Add 18 years to the dates stored in the BirthDate column, then return the updated dates.
SELECT LastName, BirthDate, DATEADD(year, 18, BirthDate) AS DateAdd FROM Employees; |