Hi, Not critical as I have a work around so this is just to help me learn/improve my code...
I would like to know if you can you set a variable when using CASE? I tried various ways but with no luck..I needed to add either 0 or 12 hours to a date based on whether the StartDate and EndDate matched...
I tried these two but failed!!...
and also..
Any pointers would be appreciated..
I would like to know if you can you set a variable when using CASE? I tried various ways but with no luck..I needed to add either 0 or 12 hours to a date based on whether the StartDate and EndDate matched...
I tried these two but failed!!...
Code:
CASE WHEN START_DATE = SESS_END_DATE THEN SET @Hours = 0 ELSE SET @Hours = 12 END
DATEADD(hh, @Hours, START_DATE)
and also..
Code:
SET @Hour = CASE WHEN START_DATE = SESS_END_DATE THEN 0 ELSE 12 END
DATEADD(hh, @Hours, START_DATE)
Any pointers would be appreciated..