一、计算2个时间之间的间隔
select TIMESTAMPDIFF(year, '2024-12-30' ,now())
select TIMESTAMPDIFF(month, '2024-12-30' ,now())
select TIMESTAMPDIFF(day, '2024-12-30' ,now())
二、按照年、月、周 分组统计
SELECT YEAR(create_time) AS order_year,WEEK(create_time, 1) AS order_week,count(id)FROM sbsj_gzGROUP BY order_year, order_weekORDER BY order_year, order_week