mysql 获取当月所有日期列表

select date from (
SELECT DATE_FORMAT(DATE_SUB(last_day(curdate()), INTERVAL xc-1 day), '%Y-%m-%d') as date
FROM (
SELECT @xi:=@xi+1 as xc from
(SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6) xc1,
(SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6) xc2,
(SELECT @xi:=0) xc0
) xcxc)
x0 where
x0.date >= (select date_add(curdate(),interval-day(curdate())+1 day))
ORDER BY date ASC

posted @ 2023-02-15 14:54  南国的刘新  阅读(320)  评论(0)    收藏  举报