mysql 生成上周 上月上季第一天时间

SELECT CURDATE() AS today,
DATE(CONCAT(YEAR(CURDATE()),'-',ELT(QUARTER(CURDATE())-1,1,4,7,10),'-',1)) AS firstdayofQ
,DATE(CONCAT(YEAR(CURDATE()),'-',MONTH(CURDATE())-1,'-','1')) AS firstdayofM
,DATE(DATE_SUB(CURDATE(), INTERVAL WEEKDAY(CURDATE()) + 7 DAY)) AS firstdayofW

你可能感兴趣的:(mysql)