TO_DAYS(create_time) = TO_DAYS(NOW())//今日
YEARWEEK(date_format(create_time,'%Y-%m-%d')) = YEARWEEK(now())//本周
DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(create_time)//近一周(七天)
date_format(create_time,'%Y-%m')=date_format(now(),'%Y-%m')//本月
DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(create_time)//近一月(30天)
date_format(create_time,'%Y-%m')=date_format(DATE_SUB(curdate(), INTERVAL 1 MONTH),'%Y-%m')//上个月
QUARTER(create_time)=QUARTER(now())//本季度
QUARTER(create_time)=QUARTER(DATE_SUB(now(),interval 1 QUARTER))//上个季度
date_format(create_time,'%Y-')=date_format(now(),'%Y-')//本年
YEAR(create_time)=YEAR(date_sub(now(),interval 1 YEAR))//上一年
【小计】最近常用mysql查询时间
最新推荐文章于 2025-04-04 21:41:22 发布