SQLTeam.com | Weblogs | Forums

Finding 1 week Prior



I am using this where clause in my query below. This gives me a week of data. How do I get the prior week of data. example I want to pull 3/28 through 4/1.

(YEAR([clm_rcvd]) = YEAR(GETDATE())) AND (DATEPART(wk, [clm_rcvd]) = DATEPART(wk, GETDATE())))


basically, replace GETDATE() with
DATEADD(week, -1, GETDATE())


Maybe I'm overthinking or just plain misunderstood the question, but here's an alternative:

select ...
  from ...
 where clm_rcvd>=dateadd(week,datediff(week,@@datefirst,current_timestamp)-1,@@datefirst-1)
   and clm_rcvd<dateadd(week,datediff(week,@@datefirst,current_timestamp)-1,@@datefirst+6)