SQL-----Datediff,dateadd,datedepart,datename,convert

Source: Internet
Author: User

--getdate Current system date, timeSelect getdate()--2014-11-24 13:22:40.407--the CONVERT () function can display date/time data in different formatsSelect Convert(varchar( -),getdate(), at)--2014-11-24--DateDiff Returns the number of date and time boundaries across two specified datesSelect DateDiff( Day,'2014-11-24','2014-12-28')-- theSelect DateDiff(Month,'2014-11-24','2014-12-28')--1--datepart Returns an integer representing the specified date part of a specified dateSelect DatePart(Month,'2014-11-24')--NovemberSelect DatePart(Week,'2014-11-24')--48 weeksSelect DatePart(W,'2014-11-24')--2 Monday--Datename Returns a string representing the specified date part of a specified dateSelect Datename(Month,'2014-11-24')-- OneSelect Datename(Weekday,'2014-11-24')--Monday--DateAdd () function adds or subtracts a specified time interval DATEADD (datepart,number,date) in a dateSelect DateAdd( Day,2,'2014-11-24')--2014-11-26 00:00:00.000Select DateAdd(Month,-2,'2014-11-24')--2014-09-24 00:00:00.000

SQL-----Datediff,dateadd,datedepart,datename,convert

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.