SQL Date Type

Source: Internet
Author: User
Tags getdate

DECLARE @datetime datetime = Current_timestamp, @date date = Current_timestamp, @time time = Current_timestampselect @date Time--2018-06-08 09:01:10.440select @date--2018-06-08select @time--09:01:10.4400000-----------DATEADD () function to add or subtract a specified time interval from a date. ---------------------Select Dateadd (d,1, ' 2018-01-01 00:00:00.000 ')--2018-01-02 00:00:00.000------------DATEDIFF () The function returns a time between two dates. ------------------------------Select Datediff (d, ' 2018-01-01 ', ' 2018-01-02 ')--1--datename returns the string type select GETDATE () as Current date, datename (year, GETDATE ()) as years, Datename (month, GETDATE ()) as month, Datename (day, GETDATE ()) as date, Datename (quarter, GE Tdate ()) as quarter, Datename (DayOfYear, GETDATE ()) as the number of days of the Year, Datename (DW, GETDATE ()) as week, Datename (week, GETDATE ()) as weeks , Datename (Hour, GETDATE ()) as, Datename (minute, GETDATE ()) as, Datename (second, GETDATE ()) as seconds, datename (millisecond , GETDATE ()) as MS Select Datepart (yy,getdate ())--Returns the value type Select Isdate (' 2018-01-32 ')--Determines whether the string is a date, is 1, no 0select year ( GETDATE ()) as year, Month (GETDATE()) as month, Day (GETDATE ()) As date--return value type

SQL Date Type

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.