Date and Time Data Types

The date, time, datetime2, and datetimeoffset types are four date and time data types that were introduced in SQL Server 2008. These types should be used for all new database development in lieu of the traditional datetime and smalldatetime data types. The newer types are aligned with the .NET Framework, Microsoft Windows, and the SQL standard—unlike datetime and smalldatetime—and there are improvements in range, precision, and storage as well.

Separation of Dates and Times

We’ll begin by looking at the separate date and time types. If you need to store only a date value (for example, a date of birth), use the date type. Similarly, use the time type for storing just a time value (for example, a daily medication time), as ...

Get Programming Microsoft® SQL Server® 2012 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.