sql-Date function

Source: Internet
Author: User
Tags getdate

GETDATE (): Gets the current date time
DATEADD (datepart, number, date), calculates the date after the increase. The parameter date is the day to be calculated, the parameter number is increment, the parameter datepart is the unit of measurement, and the optional value is shown in remarks. DATEADD (day, 3,date) is the date 3 days after the date of the calculation, and DATEADD (month, -8,date) is the date 8 months before the date of the calculation.
(1000$ of employees with more than one year of employment), entry date + 1 year < current time
There are only datetime types in Sql2005, and 2008 has date, DateTime, DateTime2, and so on.
DATEDIFF (DatePart, StartDate, EndDate): Calculates the difference between two dates. DatePart is the unit of measure, the desirable value reference DateAdd.
Number of students with different year of enrollment:
Select DateDiff (Year,sindate,getdate ()), COUNT (*) from student Group by DateDiff (Year,sindate,getdate ())
DATEPART (datepart,date): Returns a specific part of a date
Month (), year (), Day () instead.
Count the number of birthdays of a student:
Select DatePart (Year,sbirthday), COUNT (*)
From student
GROUP by DatePart (year, Sbirthday)
The number of people born in 1990?

sql-Date function

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.