14

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?

Community
  • 1
  • 1
CJ7
  • 22,579
  • 65
  • 193
  • 321
  • Possible duplicate of http://stackoverflow.com/questions/1334143/sql-server-datetime2-vs-datetime – Marko Aug 17 '10 at 02:07
  • 3
    I have clearly referred to the DbType class found in .NET. I am using an MDB database so it has nothing to do with SQL Server. This question should not be closed! – CJ7 Aug 17 '10 at 02:16
  • To those who upvoted my comment: please vote to reopen this question. – CJ7 Aug 18 '10 at 01:28

2 Answers2

10

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!

David Hoerster
  • 28,421
  • 8
  • 67
  • 102
3

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.

Community
  • 1
  • 1
Dave Markle
  • 95,573
  • 20
  • 147
  • 170