Whenever the value is null for this query
SELECT ISNULL(someDateTime,'')
FROM someTable
the result is
someDateTime ------------ 1900-01-01 00:00:00.000
I want it to be “No”, so if I run this:
SELECT ISNULL(someDateTime,'No')
FROM someTable
then there’s this error:
Conversion failed when converting datetime from character string.
How to do it? Thanks in advance!
The result of the expression will need to be a single type. If you want a character string (and you do, since ‘No’ is not a DateTime), you’ll need to convert the datetime to such a string:
As others have suggested, though, code like this smells bad, and you may want to pass the null to a client component and do the conversion there.