datetime vs dateime2, which is the best?

Asked

Viewed 303 times

0

I’m implementing a new project, using EF6 Codefirst, EF6 creates my database Sql-Server, with date columns as type datetime.

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

1 answer

1


DATETIME2 has a larger date range than DATETIME:

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

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

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

Source: https://docs.microsoft.com/pt-br/sql/t-sql/data-types/datetime-transact-sql

Browser other questions tagged

You are not signed in. Login or sign up in order to post.