I have declared a variable @date
SELECT @date = CASE
WHEN MAX(dt) IS NULL THEN '31/12/2009'
ELSE MAX(dt) + 1
END
FROM mytab
A code snippet where I am using the local variable
CASE
WHEN MAX(DateValue)= @date THEN NULL
ELSE CONVERT(varchar(10), CONVERT(datetime, MAX(DateValue)), 103)
END AS newdt
I don't want to use the @date local variable in the case statement but want to get the same effect. I tried:
CASE
WHEN MAX(DateValue)= @isnull(dt, '31/12/2009')
ELSE CONVERT(varchar(10), CONVERT(datetime, MAX(DateValue)), 103)
END AS newdt
but receive an error. Any idea of getting rid of this?