Forums

This topic is locked

Entering a NULL value in a Date fiels in SQLserver

Posted 22 Aug 2001 22:55:05
1
has voted
22 Aug 2001 22:55:05 Wouter wvannigtevegt posted:
Hi everybody,

i'm trying to enter a NULL value in a DateTime field in SQL server, but instead SQLserver translates this to 1-1-1900...

any suggestions?

thanx,
Wouter

Replies

Replied 23 Aug 2001 18:53:17
23 Aug 2001 18:53:17 Joel Martinez replied:
Doh!!!

I have the same problem, I still haven't been able to figure it out... it got to the point that I just checked for 1/1/1900 in the code (because of the time crunch).
Hope fully someone else will know how to solve this <img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>

Joel Martinez [ ]
----------
set rs = conn.execute("SELECT answer FROM brain WHERE question = "& forumPost &"
'2nd place is just 1st Loser
Replied 24 Aug 2001 10:05:17
24 Aug 2001 10:05:17 Wouter wvannigtevegt replied:
yep, that seems to be the only solution...

give an empty date a 1-1-1900 value and put a filter in the stored procedure which replaces 1-1-1900 with Null

any other sollutions are still welcome

Wouter

Replied 24 Aug 2001 12:48:27
24 Aug 2001 12:48:27 Owen Eastwick replied:
How about:

Give the date field a default value of <b>Null</b>, then the following will work:


SELECT ID, Commment, [Date]
FROM dbo.Table1
WHERE ([Date] IS NULL)


SELECT ID, Commment, [Date]
FROM dbo.Table1
WHERE ([Date] &gt; CONVERT(DATETIME, '2001-08-02 00:00:00', 102))

Does that help?


Rgards

Owen.


Replied 24 Aug 2001 17:11:08
24 Aug 2001 17:11:08 Wouter wvannigtevegt replied:
Hi Owen,

i haven't tried it out yet, but i think it has something to do with the fact that i'm trying to insert the values with a asp string.
In a string an empty date value gets a '', which SQLserver doesn't regonize as an empty field...

Reply to this topic