Query to get the last seven week number of the year in particular for pivot.
Suppose today is 44th week then my output should be [44],[43],[42],[41],[40],[39],[38]
select datepart(ww,getdate())
,datepart(ww,dateadd(ww,-1,getdate()))
,datepart(ww,dateadd(ww,-2,getdate()))
,datepart(ww,dateadd(ww,-3,getdate()))
,datepart(ww,dateadd(ww,-4,getdate()))
,datepart(ww,dateadd(ww,-5,getdate()))
,datepart(ww,dateadd(ww,-6,getdate()))
1 Like
@bitsmed
But with this query i won't get the format which i want
You get the weeknumbers you want, right?
Now if you want to incorporate it in your query, you might want to post your query. Otherwise it's hard to help.
1 Like