sql case date variable

  1. A

    Question Using a case statement to set a variable

    Hi, I am struggling to understand what is wrong with the following... DECLARE @YEAR as varchar(4); DECLARE @MONTH as varchar(4); SET @MONTH = MONTH(DATEADD(M,1,GETDATE())); CASE @YEAR WHEN @MONTH == '12' THEN '2011'; ELSE YEAR(GETDATE()); END I receive the following error...
Back
Top