Hello,
I am using a case statement to determine if a date is null or not. Here is my code:
SELECT *,
length_of_service = case rehire_date
when rehire_date is null THEN
round(convert(decimal, datediff(dd, hire_date, getDate()))/365.2422,2)
ELSE
round(convert(decimal, datediff(dd, rehire_date, getDate()))/365.2422,2)
END,
However, I'm getting "incorrect syntax near the keyword 'is'" error. I just want to see if the rehire date is null or not. I'm not entirely sure what I'm doing wrong. Please help! Thank you.
I am using a case statement to determine if a date is null or not. Here is my code:
SELECT *,
length_of_service = case rehire_date
when rehire_date is null THEN
round(convert(decimal, datediff(dd, hire_date, getDate()))/365.2422,2)
ELSE
round(convert(decimal, datediff(dd, rehire_date, getDate()))/365.2422,2)
END,
However, I'm getting "incorrect syntax near the keyword 'is'" error. I just want to see if the rehire date is null or not. I'm not entirely sure what I'm doing wrong. Please help! Thank you.