Select Month (logintime), count (ID) from S_login_log Group by month (Logintime)
Date Function
Select Day (createtime) from Life_unite_product--the days value of the Time field
Select Month (createtime) from Life_unite_product--the month value of the Time field
Select year (createtime) from Life_unite_product--the annual value of the Time field
Select DATEPART (yy,createtime) from life_unite_product --the year value of the Time field
Select DATEPART (QQ, Createtime) from life_unite_product --the quarterly value of the Time field
Select DATEPART (mm,createtime) from Life_unite_ Product --The month value of the Time field
Select DATEPART (dy,createtime) from life_unite_product --Take the Time field as the day of the year
Select DATEPART (dd,createtime) from life_unite_product --day value for TIME field
Select DATEPART (wk,createtime) From Life_unite_product --The Time field is the first few weeks of that year
Select DATEPART (dw,createtime) from Life_unite_ Product -The Time field is the first weekday of the Week of that year (the working day is opened from Sunday)
Select DATEPART (hh,createtime) from Life_unite_ Product -the time value of the Fetch times field
Select DATEPART (mi,createtime) from life_unite_product --Minutes for time fields br> Select DATEPART (ss,createtime) from life_unite_product --The seconds value of the Time field
Select DATEPART (ms,createtime) From Life_unite_product --the millisecond value of the time field
Select DATEADD (yy,-1,createtime) from life_unite_product----fetch Time field (year is minus 1)
Select DATEADD (mm,3,createtime) from life_unite_product----fetch Time field (month is added 3)
Select DATEADD (dd,1,createtime) from life_unite_product----fetch Time field (day is added 1)
Select DATEDIFF (Yy,createtime,getdate ()) from Life_unite_product--the year difference from the current date
Select DATEDIFF (Mm,createtime,getdate ()) from life_unite_product-month difference from current date
Select DATEDIFF (Dd,createtime,getdate ()) from life_unite_product--difference in number of days from the current date
Select DATEDIFF (Mi,createtime,getdate ()) from life_unite_product--difference in minutes from the current date
Select Datename (yy,createtime) from Life_unite_product--the year value of the Time field
Select Datename (mm,createtime) from Life_unite_product--the month value of the Time field
Select Datename (dd,createtime) from Life_unite_product--the day value of the Time field
Select GETDATE ()--Take the current time
1, Day (date_expression)
Returns the date value in Date_expression
2, Month (date_expression)
Returns the month value in Date_expression
3, Year (date_expression)
Returns the year value in Date_expression
4, DATEADD ()
DATEADD (,,)
Returns a new date that is generated by the specified date plus the specified extra date interval. The parameter "DatePart" takes the following values:
5, DATEDIFF ()
DATEDIFF (,,)
Returns the difference in datepart between the two specified dates, that is, the date2 exceeds the date1 gap value, and the resulting value is an integer value with a positive sign.
6, Datename ()
Datename (,)
Returns this part of the specified part of the date as a string. specified by DatePart.
7, DATEPART ()
DATEPART (DATEPART, date)
Returns the specified portion of a date as an integer value. This section is specified by DatePart.
DATEPART (dd, date) is equivalent to day (date)
DATEPART (mm, date) is equivalent to month (date)
DATEPART (yy, date) is equivalent to year (date)
The following table lists the DATEPART options and the abbreviations identified by the SQL Server Compact Edition:
Date part abbreviation
Year yy, yyyy
Quarterly QQ, Q
month mm, M
One day of the year dy, y
Date DD, D
Week wk, WW
Weekday * DW
Hour HH
Minutes mi, n
Second SS, S
Millisecond MS
8, GETDATE ()
Returns the current date and time of the system in DateTime's default format