SyntaxTerror
Technical User
I'm writing a report that will go back from the current date and break it up into weekly periods, so I wanted to use DATEADD to achieve this by doing something like...
DECLARE @CurrDate as TimeStamp
SELECT CASE WHEN CreatedDate BETWEEN DATEADD(D, -7, @CurrDate) and DATEADD (D, 1, @CurrDate) THEN 'pass' ELSE 'fail' END AS 'Last Week'
...then I'd do another case for D, -14 and D, -7 or something like that.
It keeps spitting out "fail", but when I actually replace the DATEADD function with the expected dates, it spits out "pass".
What am I doing wrong?
Any and all help is appreciated! Thank you!
DECLARE @CurrDate as TimeStamp
SELECT CASE WHEN CreatedDate BETWEEN DATEADD(D, -7, @CurrDate) and DATEADD (D, 1, @CurrDate) THEN 'pass' ELSE 'fail' END AS 'Last Week'
...then I'd do another case for D, -14 and D, -7 or something like that.
It keeps spitting out "fail", but when I actually replace the DATEADD function with the expected dates, it spits out "pass".
What am I doing wrong?
Any and all help is appreciated! Thank you!