Difference between SQLServerdate, datetime, and smalldate

Source: Internet
Author: User
Environment: SQLServer2008R2 problem: difference between SQLServerdate, datetime, and smalldate: datetime data from January 1, January 1-9, 1753 to January 1, December 31, 999, with an accuracy of 3% seconds (equal to 3.33 milliseconds or 0.00333 seconds ). As shown in the following table, adjust the increment to. 000,. 003, or. 007 seconds. Date and

Environment: SQLServer 2008 R2 problem: date, datetime, smalldate difference solution: datetime from January 1, 3% date and time data, precision is 3.33 seconds (equal to 0.00333 milliseconds or seconds ). As shown in the following table, adjust the increment to. 000,. 003, or. 007 seconds. Date and

Environment: SQLServer 2008 R2

Problem: difference between SQLServer date, datetime, and smalldate


Solution:


Datetime

From the date and time data of January 1, 3% to 3.33 seconds (equivalent to 0.00333 milliseconds or seconds ). As shown in the following table, adjust the value to an increment of. 000,. 003, or. 007 seconds.

The date and time section can indicate that the date range is from 00:00:00. 000 on January 1, January 1, 1753 AD to 23:59:59. December 31, 9999 on January 1, 997, accurate to 3.33 milliseconds. It requires 8 bytes of storage space.

Smalldatetime

The date and time data from January 1, January 1-20, 1900 to January 1, June 6 are accurate to minutes. The smalldatetime value of 29.998 s or lower is rounded down to the nearest minute, And the smalldatetime value of 29.999 s or higher is rounded up to the nearest minute. It requires 4 bytes of storage space.

Date

SQL Server 2008 introduces new data types. It indicates a day, excluding the time part. It can represent the date range from January 1, January 1-9, December 31, 999, the first year of the year. It only requires three bytes of storage space.


When reading this data, no matter whether your field is datetime or smalldatetime, the read format is the same (for example ). Datetime does not display its millisecond, but it will appear in milliseconds during time comparison, so that the two time periods cannot be equal.

References:

Http://topic.csdn.net/t/20061024/20/5106333.html

Http://www.cnblogs.com/SAL2928/archive/2007/06/01/767431.html

Http://zhidao.baidu.com/question/319116298.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.