Q&A for professional mathematicians
SELECT ---https://stackoverflow.com/questions/1267126/get-the-week-start-date-and-week-end-date-from-week-number DATEADD(dd, -(DATEPART(dw, CreationDate)-1), CAST(CreationDate AS Date)) [WeekStart], COUNT(Id) AS Count FROM Users WHERE (CreationDate >= '##Date1?2021-01-01##') AND (CreationDate <= '##Date2?2023-01-01##') GROUP BY DATEADD(dd, -(DATEPART(dw, CreationDate)-1), CAST(CreationDate AS Date)) ORDER BY DATEADD(dd, -(DATEPART(dw, CreationDate)-1), CAST(CreationDate AS Date))