How does SqlDateTime do its precision reduction

前端 未结 3 597
深忆病人
深忆病人 2021-01-19 02:35

Consider the following program:

DateTime dateTime = new DateTime(634546165144647370);
SqlDateTime sqlDateTime = new SqlDateTime(dateTime);

Console.WriteLine         


        
3条回答
  •  悲&欢浪女
    2021-01-19 03:06

    SQL Server DATETIME has an accuracy of 3.33ms - therefore, you cannot get all possible values, and there's a good chance .464 was just such a value.

    On SQL Server 2008, you could use DATETIME2 or TIME(x) datatypes which have an accuracy to 100ns - that should be plenty enough for "regular" use

提交回复
热议问题