User Comments by Year

1

Please login or register to vote for this query.

(click on this box to dismiss)

Motor Vehicle Maintenance and Repair Meta

Q&A about the site for mechanics and DIY enthusiast owners of cars, trucks, and motorcycles

-- Default to -1 if no value is entered
DECLARE @UserId INT = '##UserId##'
DECLARE @Year INT = '##Year?-1##'

-- Convert -1 to the current year
SELECT @Year = IIF(@Year = -1, YEAR(GETDATE()), @Year);

SELECT
    c.Id,
    c.PostId,
    c.Score,
    c.Text,
    c.CreationDate

FROM
    Comments c

WHERE
    c.UserId = '##UserId##'
    AND YEAR(c.CreationDate) = @Year    
--AND c.CreationDate >= '2018-01-01'
--AND c.CreationDate < '2019-01-01' --!!!

ORDER BY
    c.CreationDate;

Enter Parameters

Options:
Switch to main site
loading Hold tight while we fetch your results