Reputation: 1533
I am using MSSQL 2017 express. What i want is i want to return 4 days back data from todays date where IsaAtive is 1. I already with less then greater then sign bellow but this not works at all. Any one can fix my query so it will return is data 4 days back from today? Any example?
SQL:
Select *
From MyTableName
Where CheckedDate < '2018-09-10 00:00:00.000' AND IsActive = '1'
Upvotes: 1
Views: 1357
Reputation: 37473
Use below query: using DATEADD(day, -4,getdate()) and getdate()
Select *
From MyTableName
Where CheckedDate >= DATEADD(day, -4, getdate()) and
CheckedDate < getdate() AND IsActive = '1'
Upvotes: 1