I have a method that gets a date property from a source (either a
protected SqlDateTime GetSqlDateTimePropertyValue(string propertyName, object source)
var objValue = GetPropertyValue(propertyName, source);
var value = objValue == DBNull.Value ? null : (DateTime?)objValue;
var sqlValue = new SqlDateTime();
if (value.HasValue) sqlValue = value.Value;
Yes - the SQL Server
DATETIME has an accuracy of 3.33ms - the .NET datatype however can represent single milliseconds.
Therefore, you will have some rounding issues at times.
Read a lot more about the
DATETIME datatype and its properties and quirks here:
Also, SQL Server 2008 introduced a slew of new date-related data types - read more about those here:
These types do include a
DATETIME2 datatype which is accurate to 100ns.