In this post explains how to use the DATEADD function in SQL Server (Transact-SQL) with syntax and examples.
In SQL Server (Transact-SQL), the DATEADD function returns a date after which a certain time/date interval has been added.
The syntax for the DATEADD function in SQL Server (Transact-SQL) is:
The time/date interval that you wish to add. It can be one of the following values:
Value (any one of) | Explanation |
---|---|
year, yyyy, yy | Year interval |
quarter, qq, q | Quarter interval |
month, mm, m | Month interval |
dayofyear | Day of year interval |
day, dy, y | Day interval |
week, ww, wk | Week interval |
weekday, dw, w | Weekday interval |
hour, hh | Hour interval |
minute, mi, n | Minute interval |
second, ss, s | Second interval |
millisecond, ms | Millisecond interval |
The number of intervals that you wish to add.
The date to which the interval should be added.
The DATEADD function can be used in the following versions of SQL Server (Transact-SQL):
Let's look at some SQL Server DATEADD function examples and explore how to use the DATEADD function in SQL Server (Transact-SQL).
For example: