查看本月数据
SELECT
*
FROM
content_publish
WHERE
date_format(publish_time, ‘%Y %m‘) = date_format(DATE_SUB(curdate(), INTERVAL 0 MONTH),‘%Y %m‘)
查看上个月数据
SELECT
*
FROM
content_publish
WHERE
date_format(publish_time, ‘%Y %m‘) = date_format(DATE_SUB(curdate(), INTERVAL 1 MONTH),‘%Y %m‘)
查询上上个月数据
SELECT
*
FROM
content_publish
WHERE
date_format(publish_time, ‘%Y %m‘) = date_format(DATE_SUB(curdate(), INTERVAL 2 MONTH),‘%Y %m‘)
查询当前月份
select date_format(DATE_SUB(curdate(), INTERVAL 0 MONTH), ‘%m‘)
查询上个月月份
select date_format(DATE_SUB(curdate(), INTERVAL 1 MONTH), ‘%m‘)
查询上上个月月份
select date_format(DATE_SUB(curdate(), INTERVAL 0 MONTH), ‘%m‘)