MySQL DATEDIFF DATE_ADD计算时间

MySQL DATEDIFF函数计算时间间隔

计算table表中next_visit_dt与当前时间相差一天,+1为当前日期后一天,-1为前一天

select * from table where datediff(next_visit_dt,now()) = 1

DATE_ADD查询今年到明年数据

select count(*) from table t where t.create_time between date_format(now(),'%Y-01-01 00:00:00') and date_format(date_add(now(),interval 1 year), '%Y-01-01 00:00:00')

猜你喜欢

转载自blog.csdn.net/qq_32332777/article/details/103504387