• 13. 1. 2020
  • Ing. Jan Zedníček - Data Engineer & Controlling
  • 0

This article follows post in which I offered overview of Data types in SQL Server (more in SQL Data types – Overview ). You can find list of all system data types in it. We can now focus on another category from mentioned overview of t-sql Date and time data types.

Date data types specification will be shorter than previous article on numeral ones since there is not much to write about. It is simple.

SQL Date and Time Data Types

Data Type Range of Values Format Size
DATE 0001-01-01 to 9999-12-31 YYYY-MM-DD 3 Bytes
TIME 00:00:00.0000000 to 23:59:59.9999999 hh:mm:ss[.nnnnnnn] 3-5 Bytes
SMALLDATETIME 1900-01-01 to 2079-06-06 YYYY-MM-DD hh:mm:ss 4 Bytes
DATETIME 1753-01-01 to 9999-12-31 YYYY-MM-DD hh:mm:ss[.nnn] 8 Bytes
DATETIME2 0001-01-01 00:00:00.0000000 to 9999-12-31 23:59:59.9999999 YYYY-MM-DD hh:mm:ss[.nnnnnnn] 6-8 Bytes
DATETIMEOFFSET 0001-01-01 00:00:00.0000000 to 9999-12-31 23:59:59.9999999 (UTC) YYYY-MM-DD hh:mm:ss[.nnnnnnn] [+|-]hh:mm 8-10 Bytes

Things to point out:

  1. Data type DATETIMEOFFSET which enables user to obtain information on time zone. This might be the choice for globally focused databases
  2. DATETIME can hold dates all the way back to 1753
  3. SMALLDATETIME holds dates till 1900

More detailed information on date data types can be found on Microsoft web here

Rate this post

Ing. Jan Zedníček - Data Engineer & Controlling

My name is Jan Zedníček and I have been working as a freelancer for many companies for more than 10 years. I used to work as a financial controller, analyst and manager at many different companies in field of banking and manufacturing. When I am not at work, I like playing volleyball, chess, doing a workout in the gym.

🔥 If you found this article helpful, please share it or mention me on your website

Leave a Reply

Your email address will not be published. Required fields are marked *