1. The year of the Day (GETDATE (): 2012/05/08 18:07:26)
SELECT Year (GETDATE ())--2012
2. Find the month of the day
SELECT MONTH (GETDATE ())--5
3. Seek the day of the day
SELECT Day (GETDATE ())--8
4. Day of the month
SELECT CONVERT (Varchar,getdate (), 112)--Result: 20120508
SELECT CONVERT (Varchar,getdate (), 111)--Result: 2012/05/08
Select Convert (varchar), GETDATE (), 23)--Result: 2012-05-08
5. Two time difference function
SELECT DATEDIFF (day, ' 20120505 ', GETDATE ())--Results: 3
SELECT DATEDIFF (day,getdate (), ' 20120505 ')--results: -3
Year: Years
Month: Monthly
Day: Days
Hour: Hours
minutes: minutes
SS:seconds
SELECT DATEDIFF (SS, ' 20120508 18:09:00 ', GETDATE ())--37
6. How much time is added at a certain time
SELECT DATEADD (Hour,10,getdate ())--2012-05-09 04:10:21.773 Add 10 hours to the current time
Year: Years
Month: Monthly
Day: Days
Hour: Hours
minutes: minutes
SS:seconds
7. Datename函数获取名称;
datepart function gets月分对应值
SELECT DATEPART (Dw,getdate ()); --3
SELECT Datename (Dw,getdate ()); --Wednesday