I'm trying to add my case statment inside the condition but I think I'm not doing this right. I want to run a list of orders based on current date.
Let say if current date is monday I want to run the added orders made from friday 3pm.
And if current date is tuesday then I want to run the orders added yesterday from 3pm.
Having this condition all I have to do is to play with the getdate and dateadd. Now I'm having problems in my case condition and it looks like this.
=ORDER_CREATETI MESTAMP
Let say if current date is monday I want to run the added orders made from friday 3pm.
And if current date is tuesday then I want to run the orders added yesterday from 3pm.
Having this condition all I have to do is to play with the getdate and dateadd. Now I'm having problems in my case condition and it looks like this.
Code:
select * from orders where CASE WHEN GETDATE()=DATEADD(wk,DATEDIFF(wk,0,GETDATE()),0) --to get Monday THEN CONVERT(VARCHAR(10), DATEADD(D-3,GETDATE()), 121)+' 14:59:059.059' AND CONVERT(VARCHAR(10), GETDATE(), 121)+' 15:00:000.000' CASE WHEN GETDATE()<>DATEADD(wk,DATEDIFF(wk,0,GETDATE()),0) THEN CONVERT(VARCHAR(10), DATEADD(D,-1,GETDATE()), 121)+' 14:59:059.059' AND CONVERT(VARCHAR(10), GETDATE(), 121)+' 15:00:000.000' END
Comment