SELECT * FROM table where to_days (dateline) = To_days (now ());
SELECT * FROM table where date (dateline) = Curdate ();
--Query yesterday records
SELECT * FROM table where to_days (dateline) = To_days (now ())-1;
SELECT * FROM table where date (dateline) = Curdate ()-1; --Today is the first day of the month to find the last day of the month record
--Query this week's records
SELECT * FROM table where Yearweek (Date_format (Dateline, '%y-%m-%d ')) = Yearweek (now ());
SELECT * FROM table where Date_sub (Curdate (), INTERVAL 7 day) <= DATE (Dateline); --7 days before the check
--Query last week records
SELECT * FROM table where Yearweek (Date_format (Dateline, '%y-%m-%d ')) = Yearweek (now ())-1;
--Check this month's record
SELECT * FROM table where Date_format (Dateline, '%y%m ') = Date_format (Curdate (), '%y%m ');
SELECT * FROM table where Date_sub (Curdate (), INTERVAL 1 MONTH) <= DATE (Dateline);--30 days before check
--Query last month records
SELECT * FROM table where Period_diff (Date_format (now (), '%y%m '), Date_format (Dateline, '%y%m ')) = 1;
SELECT * FROM table where Date_format (Dateline, '%y%m ') = Date_format (Curdate (), '%y%m ')-1;
SELECT * FROM table where Date_format (Dateline, '%y-%m ') =date_format (Date_sub (Curdate (), INTERVAL 1 MONTH), '%y-%m '); --60 days to the first 30 days before the check
MySQL Query by date