Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Why 01-01-1900 00:00:00 is storing in a table?

Author  Topic 

Srikrishna.m
Starting Member

2 Posts

Posted - 2009-09-05 : 05:27:48
Hi Team,

I have small issue which I am struggling with that.
My issue is I am saving a record in which I have a datetime variable.And I am not assigning any datetime value to this variable while saving.So,it should store NULL in database by default.But,After saving,the field in the table is showing 01-01-1900 00:00:00 as the datetime but not NULL. Why this is happening...?
Any tips are appreciated...

Thanks,
M.Srikrishna Murthy

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-09-05 : 06:08:31
How are you sending dates to the table?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-09-05 : 06:13:31
it seems like your default value passed for datetime variable is 0 which is equivalent to date 01-01-1900 00:00:00
Go to Top of Page

Srikrishna.m
Starting Member

2 Posts

Posted - 2009-09-05 : 06:16:18
Hi ,
In my application data goes from the system interfaces to the DA layers.In Da layers,In insert method ,I have written the following piece of code.

parameterArray[7] = CreateParameter("StartDate", DbType.DateTime);
parameterArray[7].Value =GetParamValue(obj.StartDate);
cmdWorkOrder = CreateDbCommand(sqlQry.ToString());
//Adding parameters
cmdWorkOrder.Parameters.AddRange(parameterArray);
//Execute the Query
rowsEffected = ExecuteNonQuery(cmdWorkOrder);



M.Srikrishna Murthy
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-09-05 : 06:19:08
Make sure obj.StartDate has the correct date

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-09-05 : 06:19:14
what does GetParamValue(obj.StartDate); return as value?
Go to Top of Page
   

- Advertisement -