I’m in need of help modifying an existing case statement that has to be changed to accommodate the possibility of a null value.
Currently, the statement is as follows:
CASE WHEN
DATEDIFF(dd, table.OpenDate, GetDate()) - table.Days_as_Integer) > 0 THEN
DATEDIFF(dd, table.OpenDate, GetDate()) - table.Days_as_Integer
ELSE NULL END
AS Days_Past_Due
I just want to change the existing CASE statement to be able to handle a null table.OpenDate field, returning a NULL as Days_Past_Due. Is there an easy way to do this?
Thanks!!!
Instead of making your expression more complex, you should simplify it: