Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

1-1-1900 date inserted automatic to the DB

Status
Not open for further replies.

Albano

Instructor
Dec 11, 2000
221
PT
Hi,

Can someane, knows whay when make a insert to a date/time field in SQL Server, when the field is empty("") SQL put 1-1-1900 insted of nothing("")?

Can this be resolved by inserting <NULL> em the field is empty, if so how can I do dis?
Thanks,

Albano
 
1-1-1900 is the equivilant of nothing for a date because of the way dates are stored by your database.

A date is stored as an offset from a particular day.

So your database uses 1-1-1900 as this particular day. So, if you stored today's date in your database, the value actually stored would be the amount of time to add to 1-1-1900 to reach today's date.
 
if the datatype is a Datetime datatype then it will accept NULLs, jsut make sure if your clearing out a certain entry that you reset that feild to NULL instead of "". if this doesn't work, then it might be an issue with the platform your working on. SQL server enterprise manager is the one i work on and will allow NULLs in a datetime field

--there are 10 types of people in this world. those who know binary, and those who don't.--
 
And yes, as long as your field is set to allow null then you can put a null as the value.
 
1-1-1900 is the default value that sql server uses when you dont enter any value for your date field. You have to specify that you need to either enter NULL or "".

-DNG
 
Thanks, but how do I say ASP to insert null?

I have a variable thas store de data value like this:

if request("dt1")="" then dt1="" else dt1=request("dt1")

can I just put dt="NULL" ?

Albano
 
Thanks, but how do I say ASP to insert null?

I have a variable thas store de data value like this:

if request("dt1")="" then dt1="" else dt1=request("dt1")

can I just put dt1="NULL" ?

Albano
 
lets say for example you are doing an insert...do something like this

INSERT INTO mytable(myfield, datefield) VALUES ( 'blah','')

-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top