difference between DateTime and DateTime2 [duplicate]

十年热恋 提交于 2019-12-23 07:37:08

问题


Possible Duplicate:
SQL Server datetime2 vs datetime

What is the difference between DbType.DateTime and DbType.DateTime2 in .NET?

If I am using DbType.Date and I want to change to a DateTime type should I use DateTime or DateTime2?


回答1:


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.

This MSDN link explains it pretty well.

Hope this helps!




回答2:


DbType.DateTime2 and DbType.DateTime mirror exactly the types found in SQL Server as stated by this post.

When I do SQL Server work, I don't usually need that extra resolution, nor do I go back to 1753, so in .NET I tend to use System.DateTime for this and not either one. If you need to go way back in time or need mad precision, use DbType.DateTime2 paired with a SQL Server type of DateTime2.

So in short, if you're programming using Access, you probably shouldn't be using either one.



来源:https://stackoverflow.com/questions/3498817/difference-between-datetime-and-datetime2

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!