Q&A for pro webmasters
DECLARE @StartDate datetime = '2010-01-01'; DECLARE @EndDate datetime = '2024-11-01'; SELECT dateadd(month, datediff(month, 0, creationdate), 0), count(*) FROM posts WHERE posttypeid = 1 AND creationdate BETWEEN @StartDate AND @EndDate GROUP BY dateadd(month, datediff(month, 0, creationdate), 0) ORDER BY dateadd(month, datediff(month, 0, creationdate), 0)