Start The First Day Of The Week As Sunday In Sql
I want my first day of the week to be as Sunday but my issue with my code is that it starts always as Monday. SELECT UID, DATEADD(DD,CONVERT(INT, (DATEDIFF(DD, '1/1/1900',
Solution 1:
This should do the trick:
SELECT
UID,
DATEADD(d, -1, DATEDIFF(d, -1, t.DT)/7 * 7) [WeekBeginDate] ,
SUM(HOURS) AS TOTAL_HOURS
FROM myTable t
WHERE DT >= DATEADD(WEEK, -6, GetDate())
GROUP BY UID, DATEDIFF(d, -1, t.DT)/7
Post a Comment for "Start The First Day Of The Week As Sunday In Sql"