New date type for SQL Server

Source: Internet
Author: User
Tags getdate

New Date Type: is a date type that appears in 2008 that is not in 2005.

1,date data type 2,time data type 3, datetime2 data type 4, DateTimeOffset data type

1,date data type Date. Format: YYYY-MM-DD Comment: The supported range is from ' 1000-01-01 ' to ' 9999-12-31 '. Its existence avoids the time when we value the data outside of the date 12AM

DECLARE @Date as Date SET @Date =getdate () print @Date results: 2017-04-03

The 2,time data type is exactly the same as the date type. He can only take the value of the time part, excluding the value of the date part.

DECLARE @time as time SET @time =getdate () [email protected] Results: 16:50:01.1830000

3, the DateTime2 data type increases from a datetime to a maximum range of 7 means that the number of decimal digits can take 7 digits if the number of decimal digits is 0.

DECLARE @DATETIME2 as DATETIME2 (0) SET @DATETIME2 =getdate () print @DATETIME2 results: 2017-04-03 16:57:32
DECLARE @DATETIME2_ as DATETIME2 (7) SET @DATETIME2_ =getdate () print @DATETIME2_ results: 2017-04-03 16:57:32.3230000

4, DateTimeOffset data type the existence of this data type I think he's just trying to solve the problem of time zone difference: His presence can take time to do +/-hh:mm (for example, US and China time difference 12 hours)

DECLARE @DATETIMEOFFSET_ as DATETIMEOFFSET (0) SET @DATETIMEOFFSET_ = ' 2017-12-04 21:21:21-12:00 ' minus 12 hours

New date type for SQL Server

Related Article

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.