mysql计算当前日期上一周的开始日期与结束日期

SELECT YEAR, 
WEEK, 
xx.start, 
SUBSTR(ADDDATE(xx.start, 6),6,10) AS END 
FROM (
SELECT ADDDATE(jan1, (t.week - WEEK(jan1, 5)) * 7 - WEEKDAY(jan1)) AS START, 
YEAR,WEEK FROM (SELECT MAKEDATE((SELECT SUBSTR(DATE_SUB(SUBSTR(CURDATE(),1,10), 
INTERVAL 1 WEEK),1,4)), 1) AS jan1, 
SUBSTR(DATE_SUB(SUBSTR(CURDATE(),1,10), INTERVAL 1 WEEK),1,4) AS YEAR, 
WEEKOFYEAR(DATE_SUB(CURDATE(), INTERVAL 1 WEEK)) AS WEEK) t
)xx

你可能感兴趣的:(mysql)