Collections:
Date and Time Data Types in SQL Server Transact-SQL
What are date and time data types supported in SQL Server Transact-SQL?
✍: FYIcenter.com
Date and time data types are used to hold dates and times.
There are 6 date and time data types supported in SQL Server Transact-SQL:
1. DATETIME - Use to hold date and times with a large precision using 8-byte storages: 4 bytes for the date part and 4 bytes for the time part. DATETIME values are in the range of January 1, 1753 to December 31, 9999 with a precision of 3.33 milliseconds.
In other words, DATETIME should be used to record date and time at the 0.01 second (10 millisecond) level, not the millisecond level.
2. SMALLDATETIME - Use to hold date and times with a small precision using 4-byte storages: 2 bytes for the date part and 2 bytes for the time part. SMALLDATETIME values are in the range of January 1, 1900 to June 6, 2079 with a precision of 1 minute.
In other words, SMALLDATETIME should be used to record date and time at the minute level, not the second level.
3. DATE - Use to hold dates in the range of 0001-01-01 to 9999-12-31.
4. TIME - Use to hold times with different scales specified in the format of TIME(s), where s is the scale of the fractional part of a second.
5. DATETIMEOFFSET - Used to hold dates and times with timezone offsets with different scales specified in the format of DATETIMEOFFSET(s), where s is the scale of the fractional part of a second.
6. DATETIME2 - Used to hold dates and times with different scales specified in the format of DATETIME2(s), where s is the scale of the fractional part of a second.
Here are some good examples of date and time values:
PRINT '2107-05-19 22:52:51.607'; -- DATETIME PRINT '2107-05-19 22:52:00'; -- SMALLDATETIME PRINT '2107-05-19 22:52:00.1234567'; -- DATETIME2
⇒ Entering Date and Time Values in SQL Server
⇐ Differences of DECIMAL and FLOAT in SQL Server
2017-04-15, 1769🔥, 0💬
Popular Posts:
How to download Microsoft SQL Server 2005 Express Edition in SQL Server? Microsoft SQL Server 2005 E...
How To Start MySQL Server in MySQL? If you want to start the MySQL server, you can run the "mysqld" ...
What Is ISAM in MySQL? ISAM (Indexed Sequential Access Method) was developed by IBM to store and ret...
How To Convert Binary Strings into Integers in SQL Server Transact-SQL? Binary strings and integers ...
How To Convert a Unicode Strings to Non-Unicode Strings in SQL Server Transact-SQL? Since Unicode ch...