Issue
Which one:
datetime- href="https://msdn.microsoft.com/en-us/library/bb677335.aspx" rel="noreferrer">
datetime2
is the recommended way to store date and time in SQL Server 2008+?
I'm aware of differences in precision (and storage space probably), but ignoring those for now, is there a best practice document on when to use what, or maybe we should just use datetime2 only?
Solution
The MSDN documentation for datetime recommends using datetime2. Here is their recommendation:
Use the
time,date,datetime2anddatetimeoffsetdata types for new work. These types align with the SQL Standard. They are more portable.time,datetime2anddatetimeoffsetprovide more seconds precision.datetimeoffsetprovides time zone support for globally deployed applications.
datetime2 has larger date range, a larger default fractional precision, and optional user-specified precision. Also depending on the user-specified precision it may use less storage.
Answered By - Adam Porad Answer Checked By - Senaida (sql.easybugfix Volunteer)
Post a Comment
Post a Comment