ETLSQL Queries

How to Subtract Days from DateTime in SQL Server?

By 25/11/2022 October 8th, 2023 No Comments

We can use DATEADD() function to Subtract days from DateTime in Sql Server.

DATEADD() functions first parameter value can be day or dd or d all will return the same result.

Here is the query which shows how we can get date of  last week from Current DateTime in Sql Server.

Script Snippet:

SELECT GETDATE() ‘Today’,
DATEADD(day,-7,GETDATE()) ‘Last week’
SELECT GETDATE() ‘Today’,
DATEADD(dd,-7,GETDATE()) ‘Last week’
SELECT GETDATE() ‘Today’,
DATEADD(d,-7,GETDATE()) ‘Last week’

Leave a Reply