Mysql query data for this week, last week, this month, and last month SELECT name, submittime FROM enterprise where yearweek (date_format (submittime, '% Y-% m-% D') = YEARWEEK (now (); query the SELECT name, submittime FROM enterprise where yearweek (date_format (submittime, '% Y-% m-% D') = YEARWEEK (now ()-1; query the data of the current month select name, submittime from enterprise where dateformat (submittime, '% Y-% m') = dateformat (now (),' % Y-% m') query select name of data 6 months from the current time, submittime from enterprise where submittime between date_sub (now (), interval 6 month) and now (); query the select name, submittime from enterprise where dateformat (submittime, '% Y-% m') = dateformat (DATE_SUB (curdate (), INTERVAL 1 MONTH),' % Y-% m') select * from user where DATEFORMAT (pudate, '% Y % m') = DATEFORMAT (CURDATE (),' % Y % m'); select * from user where WEEKOFYEAR (FROM_UNIXTIME (pudate, '% y-% m-% D') = WEEKOFYEAR (now () select * from user where MONTH (FROM_UNIXTIME (pudate, '% y-% m-% D') = MONTH (now () select * from user where YEAR (FROM_UNIXTIME (pudate, '% y-% m-% D') = YEAR (now () and MONTH (FROM_UNIXTIME (pudate,' % y-% m-% D ')) = MONTH (now ())