简体   繁体   English

SQL Server日期时间舍入

[英]SQL Server datetime rounding

According to MSDN "Rounding of datetime Fractional Second Precision" it should truncate the following Date when saving into a datetime column: 根据MSDN “Rounding of datetime Fractional Second Precision”,它应该在保存到datetime列时截断以下日期:

new DateTime(635180453197748530L)  //22 October 2013 13:28:39.7748530
// write to SQL server and re-read it
// result should be = 6351804531977 3 0000L

However, it is reproducible 6351804531977 7 0000L . 但是,它是可重现的6351804531977 7 0000L Is this a bug or do I have any problems in my understanding of the algorithm? 这是一个错误还是我对算法的理解有任何问题?

(we use Entity Framework for read/write to DB) (我们使用Entity Framework读取/写入DB)

有时在我向数据库写一个日期时间之前,我把它转换为SqlDateTime,我发现它在舍入/截断方面比直接将CLR数据类型直接写入数据库产生了更多可预测的结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM