There are several text fields on our web forms. The fields can be either empty or a date. If it is empty we will assign a default date value and save it in sql server 2005. The default value is
DateTime dt = new DateTime(1900, 1, 1);
Before yesterday, the data is saved as "1900-01-01 00:00:00" in the database server, but it was suddenly changed and saved as "1900-01-01 12:00:00" that is PM and 12 hrs different from the old values 00:00:00. Our DBA monitored the insert process and found the value passed from web to database is "1/1/1900 12:00:00", so sql server saved it as "1900-01-01 12:00:00". The DBA said the value passed is "1/1/1900 00:00:00" before the issue. We have to changed the code to
DateTime dt = new DateTime(1900, 1, 1, 0, 0, 0);
That fixes the issue and date saved back to "1900-01-01 00:00:00". The thing I don't understand is that we didn't have code / Server changed that night, why everything is changed suddenly and strangely. The insert script generated from the web server with either old code or modified code is "insert into tablesname values('1/1/1900 12:00:00 AM')"
Does anyone have this similar issue before or can someone tell me what cause the datetime is changed during the executenoquery?
Thanks in advance!
View Complete Post