1. Get the current time
SELECT GetDate ();
2. Get time in separate years, months, days and hours, minutes, seconds
Year (GetDate ()) part of the current time
Month (GetDate ()) monthly part of the current time
Day part of the current time (GetDate ())
The above function, in turn, returns the value of type int, which returns nvarchar
Datename (year, GetDate ())
Datename (MONTH, GetDate ())
Datename (Day, GetDate ())
3. Calculate a time interval of two date types
DATEDIFF (year, ' 2013-01-01 ', ' 2014-01-01 ') returns 1
DATEDIFF (MONTH, ' 2013-01-01 ', ' 2014-01-01 ') returns 12
DATEDIFF (Day, ' 2013-01-01 ', ' 2014-01-01 ') returns 365
4. Time plus minus
DATEADD (Day, GETDATE ()) 15 days ago
DATEADD ( -15, Day, GETDATE ()) 15 days later
5. Time interception
CONVERT (varchar), GETDATE (), 1) return 05/16/06
The significance of the specific elaboration is here: http://msdn.microsoft.com/zh-cn/library/ms187928%28v=sql.100%29.aspx
6. Determine the day of the week
Select DATEPART (dw,getdate ())-1
7. Judge the first quarter of the day
(MONTH (GetDate ())-1)/4 +1
SQL Server common time-processing functions