>Hello, I'm trying to do a simple select but is displaying in two of my datetime columns the result 01-01-1900 00:00:00.000 even when the value is NULL. Is there a way to avoid this?
Hi Edgar,
The result is null when the value is null and 01-01-1900 00:00:00.000 when the value is 01-01-1900 00:00:00.000.
When you insert blank date in datetime field the result is 01-01-1900 00:00:00.000
Try this sample code
create table #crsTest
(MyInt Int
,[MyDateTime] [datetime] NULL DEFAULT (NULL))
INSERT INTO #crsTest (MyInt) VALUES(1)
INSERT INTO #crsTest (MyInt) VALUES(2)
INSERT INTO #crsTest (MyInt,MyDateTime) VALUES(3,'')
INSERT INTO #crsTest (MyInt) VALUES(4)
INSERT INTO #crsTest (MyInt,MyDateTime) VALUES(5,'20081226 15:05:09')
SELECT * from #crsTest ORDER BY MyInt
SELECT MyInt,
CASE WHEN MyDateTime = '1900-01-01' THEN NULL ELSE MyDateTime END
from #crsTest ORDER BY MyInt
drop table #crsTest
_______________________________________________________________
Testing displays the presence, not the absence of bugs.
If a software application has to be designed, it has to be designed correctly!
_______________________________________________________________
Vladimir Zografski
Systems Analyst