datetime vs dateime2, which one is the best?

0

I'm implementing a new project, using EF6 CodeFirst , EF6 creates my Sql-Server database, with date columns like datetime .

What would be the difference between datetime and datetime2 , and which one is most likely to be used?

    
asked by anonymous 06.04.2018 / 15:08

1 answer

1

DATETIME2 has a date range greater than DATETIME :

DATETIME : 01/01/1753 E 12/31/9999 DATETIME2 : 01/01/0001 A 12/31/9999

The MSDN documentation recommends using DATETIME2 (from SQL Server 2008 ):

  

Use the time, date, datetime2, and datetimeoffset data types for the   new job. These types conform to standard SQL. They are   more portable. time, datetime2, and datetimeoffset provide more   accuracy of seconds. datetimeoffset is compatible with time zone   for globally deployed applications.

Source: link

    
06.04.2018 / 15:12