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