DATEADD SQL Server Standard Datetime Function SQL Example

The DATEADD() function is used to add or subtract a specified time interval from a given date. Lets say you want to know the date of day after x. DateADD function can resolve this issue.

DATEADD() function SQL Syntax:


Where datepart is datepart (more on datepart), number is the interval which specified how many day or month or year you want to add or subtract based on third parameter date.

DATEADD() Function SQL Example:
Let’s from today we want to add 65 days or back to 65 days then we can use the below SQL:

SELECT DATEADD(day,65,GETDATE()) [Future], DATEADD(day,-65,GETDATE()) [Past]
Posted in Database, SQL Server

Leave a Reply

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