sql - How to avoid datepart to start from new week on year change -
i have sql query using weekly data. works fine when year changes stops week on 4 days or whatever , starts new week new year. dont want that. want keep working like before. idea of how force group datepart(week, ad.xdate)
select 'playing' activity ,min(ad.xdate) xdate ,isnull(sum(t.timeperday),0) timeperday alldates ad (nolock) left join @test t on ad.xdate = t.date group datepart(week, ad.xdate) order min(ad.xdate) option (maxrecursion 0)
group datediff(week, 0, ad.xdate)
Comments
Post a Comment