Can you convert datetime to nvarchar inside a case stmt so that you can use sum?
I am using a datetime column AND getdate with a CASE statement AND I need to Sum. I get the 'Operand data type varchar is invalid for sum operator' error. I have tried starting the case statement with a convert then the sum that I need, and I've tried converting just before the case statement, among many other things. I need a sum, not a count. I have 6 more statements just like this that I need to sum on "THEN 1" and populate their own columns [0-1], [1-2], etc. Count doesn't do what I need. Following is my bare bones case statement that gives me the error. SUM(CASE WHEN (DateDiff(Day, LMS_USER.C_HIRE_DATE, getdate()) / 365.25) < 1 THEN '1' ELSE '0') END AS [0-1] Using SQL Sever 2008. Can't wait until I know all this better! Thank you!