Reputation: 872
Hi i am looking for a query that can give me notification for sale orders i made after 30 days from order date and show the notification for 4 days and disappear after that
for example if i have made sale order on 2016-01-19
after adding 30 days my start date will be 2016-02-18
and adding 4 days to current date my end date will be 2016-02-23
'
i have tried to do that using the below query but it dose not give the desired out put which is records between 2016-02-18
and 2016-02-23
output i get from below query is empty
select * from [dbo].[Orders] where [OrderDate] between Dateadd(d, 30, OrderDate) and Dateadd(d, 4, GETDATE())
Upvotes: 0
Views: 61
Reputation: 239636
I think that you're trying to find orders that occurred between 30 and 34 days ago:
select * from [dbo].[Orders]
where [OrderDate] between Dateadd(day, -34, GETDATE()) and
Dateadd(day, -30, GETDATE())
You may wish to adjust these values somewhat, especially if your OrderDate
values include times also, and because GETDATE()
values always include time.
Upvotes: 3