Mysql查询本月和上个月

MySql查询本月
select count(*) from tb_order where date_format( create_time, ‘%Y-%m’) = date_format(now(), ‘%Y-%m’)


Mysql查询上个月
select count(*) from tb_order where period_diff(date_format(now(),’%Y%m’), date_format(create_time,’%Y%m’)) = 1

猜你喜欢

转载自blog.csdn.net/jyxmust/article/details/79732156