--Show the first day of this month select DATEADD (Mm,datediff (Mm,0,getdate ()), 0) Select CONVERT (Datetime,convert (VARCHAR (8), GETDATE (), 120) + ' 01 ', 120)--show the last day of this month SELECT DATEADD (Day,-1,convert (Datetime,convert (VARCHAR (8), DATEADD (Month,1,getdate ()), 120) + ' ",") Select DATEADD (Ms,-3,dateadd (Mm,datediff (M,0,getdate ()) +1,0))--Last day of last month select DATEADD (Ms,-3,dateadd (MM, DATEDIFF (Mm,0,getdate ()), 0)--this month's first Monday SELECT DATEADD (Wk,datediff (wk,0, DATEADD (Dd,6-datepart), GETDATE ())), 0)--first day of the year Select DATEADD (Yy,datediff (Yy,0,getdate ()), 0)--last day of the year select DATEADD (yy , DATEDIFF (Yy,0,getdate ()) +1,0)--Last day of last year SELECT DATEADD (Ms,-3,dateadd (Yy,datediff (), 0))--the first day of the quarter Select DATEADD (Qq,datediff (Qq,0,getdate ()), 0)--this week's Monday SELECT DATEADD (Wk,datediff (Wk,0,getdate ()), 0)--query this month's records SELECT * from TableName WHERE DATEPART (mm, thedate) = DATEPART (mm, GETDATE ()) and DATEPART (yy, thedate) = DATEPART (yy , GETDATE ())--query this week's record SELECT * FROM tableName WHERE DATEPART (wk, thedate) = DATEPART (wk, GETDATE ()) and DATEPART (yy, thedate) = DATEPART (yy, GETDATE ()) --Query the record of the season SELECT * from TableName WHERE DATEPART (QQ, thedate) = DATEPART (QQ, GETDATE ()) and DATEPART (yy, thedate) = D Atepart (yy, GETDATE ())--get total days in the month: Select DATEDIFF (Dd,getdate (), DATEADD (mm, 1, GETDATE ())) Select DATEDIFF (day,dateadd (MM, DATEDIFF (mm, ", GETDATE ()),"), DATEADD (mm, DATEDIFF (mm, ", GETDATE ()), ' 1900-02-01 ')--Gets the current day of the week SELECT Datename ( Weekday, GETDATE ())--dateadd returns a new datetime value based on adding a period of time to the specified date, for example: Add 2 days to the date SELECT DateAdd (day,2, ' 2004-10-15 ')--return: 200 4-10-17 00:00:00.000 DATEDIFF--Returns the number of date and time boundaries across two specified dates. SELECT DATEDIFF (Day, ' 2004-09-01 ', ' 2004-09-18 ')--return: DatePart--Returns an integer representing the specified date portion of the specified date. Year, month, date, day, hour hour, divided into minute, seconds for second SELECT DATEPART (month, ' 2004-10-15 ')--return to Datename--returns the specified date part for the specified date The string Select Datename (Weekday, ' 2004-10-15 ')--Returns: Friday day (), month (), year ()--can be compared with datepart select current date = CONVERT (VA RchaR (Ten), GETDATE (), 120), Current time = CONVERT (VARCHAR (8), GETDATE (),) Select Datename (DW, ' 2004-10-15 ') select year number of weeks = Datena ME (week, ' 2004-10-15 '), today is the week of several = Datename (Weekday, ' 2004-10-15 ')