When I store date property with value DateTime.MaxValue in database and retrieve it back, the stored value does not equal to DateTime.MaxValue. The tick properties are off. Why is this?
Using MS SQL, data type for date field is 'datetime'
The default and the lowest value of a DateTime object is January 1, 0001 00:00:00 (midnight). The maximum value can be December 31, 9999 11:59:59 P.M. Use different constructors of the DateTime struct to assign an initial value to a DateTime object.
The value of this constant is equivalent to 00:00:00.0000000 UTC, January 1, 0001, in the Gregorian calendar. MinValue defines the date and time that is assigned to an uninitialized DateTime variable.
Remarks. The maximum valid date for a SqlDateTime structure is December 31, 9999.
Because SQL datetime has lower resolution.
The DateTime data type in MS SQL represents 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.
source
The DateTime value type in .Net represents dates and times from 12:00:00 midnight, January 1, 0001 Anno Domini (Common Era) through 11:59:59 P.M., December 31, 9999 A.D. (C.E.) Time values are measured in 100-nanosecond units called ticks.
source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With