Friday, June 15, 2012

System.DateTime to Sql Server Compact Edition datetime consideration

Refer to
http://technet.microsoft.com/en-us/library/ms172424(v=sql.105).aspx


Date and time data from January 1, 1753, to December 31, 9999, with an accuracy of one three-hundredth second, or 3.33 milliseconds. Values are rounded to increments of .000, .003, or .007 milliseconds.
Stored as two 4-byte integers. The first 4 bytes store the number of days before or after the base date, January 1, 1900. The base date is the system's reference date. Values for datetime earlier than January 1, 1753, are not permitted. The other 4 bytes store the time of day represented as the number of milliseconds after midnight. Seconds have a valid range of 0–59.

System.DateTime has higher precision than SqlServer datetime. Make sure:

DateTime StartTime = new DateTime(2012, 1, 1, 8, 0, 0);

No comments: