A datetime
value can't have the value 0
, so you would need to use a type that could hold both a representation of a date and 0
. That would for example be a varchar
value.
Example:
IsNull(convert(varchar(25), t.Date2, 120), '0')
Pregunta
I have the select statement. I am trying to make the t.Date2 column appear as a 0 instead of a null. As you can see I used the IsNull to show nulls as a 0. The problem is that the field is a datetime field so instead of showing 0 it shows 1900-01-01 00:00:00.000. Is there a way to make it show just a 0?
SELECT t.Name, t.Number, t.Status, t.Date1, IsNull(t.Date2, 0),
DateDiff(mi, t.Date2, GetDate()) AS TimeIdleMinutes
Thanks in advance!
Solución
A datetime
value can't have the value 0
, so you would need to use a type that could hold both a representation of a date and 0
. That would for example be a varchar
value.
Example:
IsNull(convert(varchar(25), t.Date2, 120), '0')