dbTalk Databases Forums  

sql server balnk date

microsoft.public.sqlserver.tools microsoft.public.sqlserver.tools


Discuss sql server balnk date in the microsoft.public.sqlserver.tools forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
douglas
 
Posts: n/a

Default sql server balnk date - 05-01-2009 , 01:01 AM






I want to put a blank value into a datetime field in sql server 2005. However
I am getting the date of '1/2/1900'.

In the following statement, I want to return a blank date in a column in sql
server 2005 stored procedure that is passed to a vb.net 2005 application.
Instead I am getting 1/2/1900 returned in that column.

The following is part of the stored procedure that is called by the vb.net
application.

create table testtable (tablekey as int,testdate as datetime)

insert into testtable values (1,getdate())

insert into testtable values(2,'')


The source for the first insert statement will contain a valid date.
The source for the second insert statement will not contain any date.
that is why I want the value in the second inswert statement to be blank.

Thus can you tell me how to pass a blank date value?

Reply With Quote
  #2  
Old   
Tom Cooper
 
Posts: n/a

Default Re: sql server balnk date - 05-01-2009 , 01:31 AM






A datetime column can be NULL, but if is not NULL, then it must contain both
a date and a time. If you input only a date, the time defaults to
00:00:00.000, and if you only input a time, the date defaults to Jan 1,
1900. If you don't input either, by inputing a space, it defaults to Jan 1,
1900 at 00:00:00.000. You could do,

create table testtable (tablekey as int,testdate as datetime)

insert into testtable values (1,getdate())

insert into testtable values(2,NULL)

Then, of course, your application would have to correctly handle NULL's in
that column.

Tom

"douglas" <douglas (AT) discussions (DOT) microsoft.com> wrote

Quote:
I want to put a blank value into a datetime field in sql server 2005.
However
I am getting the date of '1/2/1900'.

In the following statement, I want to return a blank date in a column in
sql
server 2005 stored procedure that is passed to a vb.net 2005 application.
Instead I am getting 1/2/1900 returned in that column.

The following is part of the stored procedure that is called by the
vb.net
application.

create table testtable (tablekey as int,testdate as datetime)

insert into testtable values (1,getdate())

insert into testtable values(2,'')


The source for the first insert statement will contain a valid date.
The source for the second insert statement will not contain any date.
that is why I want the value in the second inswert statement to be blank.

Thus can you tell me how to pass a blank date value?


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.