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', t.DT)/7)) * 7,'1/1/1900') [WeekBeginDate],
SUM(HOURS) AS TOTAL_HOURS
FROM
myTable t
WHERE
DT >= DATEADD(WEEK, -6, GetDate())
GROUP BY
UID, CONVERT(INT, DATEDIFF(DD, '1/1/1900', t.DT)/7)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…