DateTime和DateTime2之间的差异 [英] difference between DateTime and DateTime2
问题描述
.NET中的 DbType.DateTime
和 DbType.DateTime2
有什么区别?
What is the difference between DbType.DateTime
and DbType.DateTime2
in .NET?
如果我使用的是 DbType.Date
,并且想更改为DateTime类型,应该使用 DateTime
还是 DateTime2
?
If I am using DbType.Date
and I want to change to a DateTime type should I use DateTime
or DateTime2
?
推荐答案
DbType.DateTime
和 DbType.DateTime2
都映射到.NET类型的 System.日期时间
.如果需要其他精度和可追溯到1753年之前的日期,请使用 DateTime2
;否则 DateTime
就足够了.
DbType.DateTime
and DbType.DateTime2
both map to the .NET type System.DateTime
. If you need to have additional precision and dates that go back before 1753, then use DateTime2
; otherwise DateTime
will suffice.
此 MSDN链接对此进行了很好的解释.
This MSDN link explains it pretty well.
希望这会有所帮助!
这篇关于DateTime和DateTime2之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!