This article is to explain how to use the dateadd function in SQL. The Function requires three arguments in order separated by commas:
- Interval – This will always be either a DAY, MONTH, or YEAR
- Increment – This is the positive or negative integer you want the date to be adjusted by
- Expression Smalldatetime – This is the value that you want changed. It can either be a column who’s data type is smalldatetime or a manually imputed date
In the example below I am updating the EndDate column in the DateTable to be three months after the date in the BeginDate column.
update T
set EndDate = DATEADD(MONTH,3,BeginDate)
from DateTable T