Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我如何使用 mysql 获取前 3 个月的第一天?
我尝试使用以下 mysql 查询
`SELECT concat(date_format(LAST_DAY(now() - INTERVAL 90 DAY),'%Y-%m-'),'01')`
这给出了2012-11-01......在这里我需要 2013-02-01,2013-01-01,2012-12-01 作为日期。这里将更改 90 天。根据间隔日,我如何获得前一个月第一天的数量
2012-11-01
好心劝告
这应该工作
SELECT concat(date_format(LAST_DAY(now() - INTERVAL 1 MONTH),'%Y-%m-'),'01') AS day1, concat(date_format(LAST_DAY(now() - INTERVAL 2 MONTH),'%Y-%m-'),'01') AS day2, concat(date_format(LAST_DAY(now() - INTERVAL 3 MONTH),'%Y-%m-'),'01') AS day3