sql server - Start the first day of the week as Sunday in SQL -


i want first day of week sunday issue code starts monday.

select      uid,     dateadd(dd,convert(int, (datediff(dd, '1/1/1900', t.dt)/7)) * 7,'1/1/1900') [weekbegindate],      sum(hours) total_hours       mytable t       dt >= dateadd(week, -6, getdate())  group      uid, convert(int, datediff(dd, '1/1/1900', t.dt)/7) 

this should trick:

select   uid,     dateadd(d, -1, datediff(d, -1, t.dt)/7 * 7) [weekbegindate] ,   sum(hours) total_hours  mytable t  dt >= dateadd(week, -6, getdate())  group uid, datediff(d, -1, t.dt)/7 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -