inserting Null into date field insteadof "Jan 1 1900"

J

Jon Skeet [C# MVP]

sanju said:
inserting Null into date field insteadof "Jan 1 1900"

hi i am providing a html form to insert dates into sql table using
asp.net and vb.net.

when user is not entered by default it is taking as Jan 1 1900. I
want to insert null if user left date fields.

Could you post the code you're using to update the database?
 
B

Bob Lehmann

I love date-related questions in posts that are dated in the future.

The posting in HTML is pretty special too.

Bob Lehmann

inserting Null into date field insteadof "Jan 1 1900"
hi i am providing a html form to insert dates into sql table using asp.net
and vb.net.
when user is not entered by default it is taking as Jan 1 1900. I want to
insert null if user left date fields.
Thank u
san
 
C

Cowboy \(Gregory A. Beamer\) [MVP]

What database?

Normally, in SQL Server, you simply set the field to NULL and you either
a) INSERT nothing
b) INSERT a NULL

I think you may not be explicitly setting the field NULL when you get an
empty string from the text field.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
inserting Null into date field insteadof "Jan 1 1900"
hi i am providing a html form to insert dates into sql table using asp.net
and vb.net.
when user is not entered by default it is taking as Jan 1 1900. I want to
insert null if user left date fields.
Thank u
san
 
C

Cowboy \(Gregory A. Beamer\) [MVP]

yes, but he is in Kiwi land, so it is already tomorrow there. ;->

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
 
B

Bob Lehmann

Yes, but the first response to his question ocurred 28 hrs. BEFORE he asked
the question. Your response comes only 19 hours before he asked it -
SLACKER! :>).

I don't know where everybody else comes from, but where I come from, the day
has ~24 hours. So, maybe I'm wrong, but I don't don't think the Southern
hemisphere has a 4th dimension that not only adds 24 hours to a news server,
but tacks on an additinal 4+ hours just to be safe. Maybe it has something
to do with water going down the drain the wrong way - who knows???.

Alternatively, and to be fair, Jon Skeet could really, really really be on
top of things. Or, maybe all of us have our settings wrong, and sanju is the
only one who got it right.

It still cracks me up when date-related questions are asked in a post-dated
message.

Bob Lehmann
 
S

sanju

inserting Null into date field insteadof "Jan 1 1900"

hi i am providing a html form to insert dates into sql table using asp.net and vb.net.

when user is not entered by default it is taking as Jan 1 1900. I want to insert null if user left date fields.

Thank u

san
 
F

Frans Bouma [C# MVP]

sanju said:
inserting Null into date field insteadof "Jan 1 1900"

hi i am providing a html form to insert dates into sql table using asp.net
and vb.net.

when user is not entered by default it is taking as Jan 1 1900. I want to
insert null if user left date fields.

when you insert a 0 (zero) in a datetime field, you get this date, jan 1,
1900.

You should insert a NULL, not a 0.

FB
 
C

Cor Ligthert

yes, but he is in Kiwi land, so it is already tomorrow there. ;->

oh was this about outlook express, I thought I was reading the ado.net
newsgroup.

Original posting:
"inserting Null into date field insteadof "Jan 1 1900"

hi i am providing a html form to insert dates into sql table using asp.net
and vb.net.
when user is not entered by default it is taking as Jan 1 1900. I want to
insert null if user left date fields."

Now, where are we talking about OE?

You do know where Jan 1 1900 comes from, do you?
 
C

Cor Ligthert

Hi Sanju,

Try this in the situation that fits you the best this is with a datarow.

inserting Null into date field insteadof "Jan 1 1900"
hi i am providing a html form to insert dates into sql table using asp.net
and vb.net.

dr("MyDate") = DBNull.Value

I hope this helps?

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top