SQL Statistics this week, this month, next week, the next month SQL statement
/*
Table structure
Student (s#,sname,sage,ssex)--s# student number, sname student name, Sage birth date, ssex student gender save some data
INSERT into Student values (' ', n ' wwww.111cn.net ', ' 1990-01-01 ', n ' Men ')
INSERT into Student values (' ", N ' money electricity ', ' 1990-12-21 ', n ' Men ')
INSERT into Student values (' ", N ' Sun Wind ', ' 1990-05-20 ', n ' Male ')
INSERT into Student values (' ', n ' li ', ' 1990-08-06 ', n ' Men ')
INSERT into Student values (' ', n ' Zhou Mei ', ' 1991-12-01 ', n ' Women ')
Query this week's data SQL statement
SELECT * FROM student where DateDiff (Week,datename (Yy,getdate ()) + right (CONVERT (varchar (), sage,120), 6), GETDATE ()) = 0--48, query next week data SQL statement
SELECT * FROM student where DateDiff (Week,datename (Yy,getdate ()) + right (CONVERT (varchar (), sage,120), 6), GETDATE ()) = -1--49, query this month's data SQL statements
SELECT * FROM student where DateDiff (Mm,datename (Yy,getdate ()) + right (CONVERT (varchar (), sage,120), 6), getdate () = 0- -50, query the next month data SQL statements
SELECT * FROM student where DateDiff (Mm,datename (Yy,getdate ()) + right (CONVERT (varchar (), sage,120), 6), getdate () =-1
drop table STUDENT,COURSE,TEACHER,SC
*/
This section of the SQL statement can be queried, this week, this month, next week, the next month birthday related data