Hi I am trying to get :
if today is Monday then it will show result from Friday to Sunday
Else
one day before . means if today is Tue then I will show only Monday data.
--------------------------------------------------------------------
select * from POTABLE where PODATE BETWEEN
CASE
WHEN
DATENAME(WEEKDAY, GETDATE())='Monday'
THEN
CONVERT(CHAR(8), GETDATE(), 112)-3 AND CONVERT(CHAR(8), GETDATE(), 112)
ELSE
CONVERT(CHAR(8), GETDATE(), 112)-1 AND CONVERT(CHAR(8), GETDATE(), 112)
END
error
Incorrect syntax near the keyword 'AND'
please note my PODATE is 'yyyymmdd' format. where I am making mistake your help is appreciated. Thanks
if today is Monday then it will show result from Friday to Sunday
Else
one day before . means if today is Tue then I will show only Monday data.
--------------------------------------------------------------------
select * from POTABLE where PODATE BETWEEN
CASE
WHEN
DATENAME(WEEKDAY, GETDATE())='Monday'
THEN
CONVERT(CHAR(8), GETDATE(), 112)-3 AND CONVERT(CHAR(8), GETDATE(), 112)
ELSE
CONVERT(CHAR(8), GETDATE(), 112)-1 AND CONVERT(CHAR(8), GETDATE(), 112)
END
error
Incorrect syntax near the keyword 'AND'
please note my PODATE is 'yyyymmdd' format. where I am making mistake your help is appreciated. Thanks
Last edited: