轮.NET日期时间毫秒,因此它可以适应的SQL Server毫秒 [英] Round .NET DateTime milliseconds, so it can fit SQL Server milliseconds
问题描述
我要datetime值转换为我将从SQL Server 2008中获得的价值。
I want to convert the datetime value to the value that I will get from SQL Server 2008.
SQL Server的截断毫秒到3位数,所以我已经截断毫秒。但问题是,你可以在这里看到:<一href=\"http://stackoverflow.com/questions/634122/milliseconds-wrong-when-converting-from-xml-to-sql-server-datetime\">http://stackoverflow.com/questions/634122/milliseconds-wrong-when-converting-from-xml-to-sql-server-datetime. SQL Server还拥有一个precision问题。
SQL Server truncate the milliseconds to 3 digits, so I truncate the milliseconds already. But the problem is that as you can see here: http://stackoverflow.com/questions/634122/milliseconds-wrong-when-converting-from-xml-to-sql-server-datetime. SQL Server also has an precision issue.
推荐答案
下面是你想要的:
using System.Data.SqlTypes; // from System.Data.dll
public static DateTime RoundToSqlDateTime(DateTime date)
{
return new SqlDateTime(date).Value;
}
这篇关于轮.NET日期时间毫秒,因此它可以适应的SQL Server毫秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!