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:

dbtut
Author: dbtut

We are a team with over 10 years of database management and BI experience. Our Expertises: Oracle, SQL Server, PostgreSQL, MySQL, MongoDB, Elasticsearch, Kibana, Grafana.

Leave a Reply

Your email address will not be published. Required fields are marked *