In MYSQL, take the first day of the current year and the current week, month, the first day of the quarter/the last day of mysql to obtain the format of the first day of the year, month, and day:
SELECT DATE_SUB(CURDATE(),INTERVAL dayofyear(now())-1 DAY);
[SQL] obtain the first DAY of the current week, month, and quarter in MySQL/the first DAY of the last DAY of the current week: select date_sub (curdate (), INTERVAL WEEKDAY (curdate () + 1 DAY) the last DAY of the current week: select date_sub (curdate (), interval weekday (curdate ()-5 days) the first DAY of the previous week: select date_sub (curdate (), interval weekday (curdate () + 8 DAY) the last DAY of the previous week: select date_sub (curdate (), interval weekday (curdate () + 2 DAY) first DAY of the first two week: select date_sub (curdate (), interval weekday (curdate () + 15 DAY) Last DAY of the first two week: select date_sub (curdate (), interval weekday (curdate () + 9 DAY) the first DAY of the current month: SELECT concat (date_format (LAST_DAY (now (), '% Y-% m -'), '01') Last day of the current month: SELECT LAST_DAY (now () First day of the previous month: SELECT concat (date_format (LAST_DAY (now ()-interval 1 month ), '% Y-% m-'), '01') the last day of the previous month: the first day of the first two months of SELECT LAST_DAY (now ()-interval 1 month: SELECT concat (date_format (LAST_DAY (now ()-interval 2 month), '% Y-% m-'), '01') the last day of the first two months: SELECT LAST_DAY (now ()-interval 2 month) the first day of the current quarter: select concat (date_format (LAST_DAY (MAKEDATE (EXTRACT (year from curdate (), 1) + interval QUARTER (CURDATE () * 3-3 month), '% Y-% m-'), '01') the last day of the current quarter: select LAST_DAY (MAKEDATE (EXTRACT (year from curdate (), 1) + interval QUARTER (CURDATE () * 3-1 month) the first day of the previous quarter: select concat (date_format (LAST_DAY (MAKEDATE (EXTRACT (year from curdate (), 1) + interval QUARTER (CURDATE () * 3-6 month ), '% Y-% m-'), '01') Last day of the previous quarter: select LAST_DAY (MAKEDATE (EXTRACT (year from curdate (), 1) + interval QUARTER (CURDATE () * 3-4 month) first two quarter's first day: select concat (date_format (LAST_DAY (MAKEDATE (EXTRACT (year from curdate (), 1) + interval QUARTER (CURDATE () * 3-9 month), '% Y-% m-'), '01') the last day of the first two quarter: select LAST_DAY (MAKEDATE (EXTRACT (year from curdate (), 1) + interval QUARTER (CURDATE () * 3-7 month)