CASTing a datetime to string if null value - keeping original datetime formatting
问题 I have the following part of my query: ISNULL(cast(fd.decision_date as varchar(20)), 'PENDING') as facility, ISNULL(cast(cd.decision_date as varchar(20)), 'PENDING') as corporate, ISNULL(cast(cb.creation_date as varchar(20)), 'PENDING') as billing My values are originally of datetime datatype, but what I want to do is return the word 'PENDING' if the value is NULL. With the code above, my results are cast ed to a varchar , thus returning something like: Aug 20 2013 9:35AM instead of 2013-08