Why is my default date always getting set to 1900-01-01 00:00:00.000

How do i set my default value for a datetime column to be null and not 1900-01-01 00:00:00.000?

Thanks
Webbo
Webbo_1980Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Reza RadConsultant, TrainerCommented:
set your column as nullable,
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
how did you define the default value?

you must allow nulls, and say NULL as default value, not "0" or "" or something like that.
0
Reza RadConsultant, TrainerCommented:
alter table Blah alter column blahblah float null
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Webbo_1980Author Commented:
My column is nullable but My default value is ((0))

Is this the cause of the problem?
0
_agx_Commented:
Just define the column to allow NULLs, and the default value will be NULL.  

ie  CREATE TABLE SomeTable ( StringCol varchar(50), DateTimeCol datetime NULL)
     INSERT INTO SomeTable ( StringCol ) VALUES ('Test1')

    Results:
    Test1      |   NULL

> Why is my default date always getting set to 1900-01-01 00:00:00.000

    Most commonly, it can happen if you insert a value like "0" or an empty string "".
    Both of those values are implicitly converted to the date 1900-01-01 00:00:00.000

   INSERT INTO SomeTable ( StringCol, DateTimeCol ) VALUES ('Test2', '')
   INSERT INTO SomeTable ( StringCol, DateTimeCol ) VALUES ('Test2', 0)

Results:
Test2      | 1900-01-01 00:00:00.000
Test2      | 1900-01-01 00:00:00.000
0
_agx_Commented:
> My default value is ((0))
> Is this the cause of the problem?

   Yes. MS SQL will convert 0 to 1900-01-01 00:00:00.000.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Guy Hengel [angelIII / a3]Billing EngineerCommented:
>but My default value is (NULL)
0
Reza RadConsultant, TrainerCommented:
you must set default value to NULL instead of 0
0
shivanshuvermaCommented:
set default value to null for ur datimetime column,it must help u
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.