Site icon Database Tutorials

DATEADD Function in SQL Server(TSQL)

 

With the DATEADD function we can add or remove a datepart to a date. Below is a list of the dateparts we can add.

The DATEADD Function is one of the most used date functions.

datepart Abbreviations
year yy, yyyy
quarter qq, q
month mm, m
dayofyear dy, y
day dd, d
week wk, ww
weekday dw, w
hour hh
minute mi, n
second ss, s
millisecond ms
microsecond mcs
nanosecond ns

Let’s make examples for a better understanding of DATEADD Function.

Add year to a date using DATEADD Function:

Add week to a date using DATEADD Function:

You can use DATEADD function as follows:

Remove week from a date using DATEADD Function:

Exit mobile version