select * from test where adddate>=’2023-01-01 00:00:00′ and adddate<=’2023-12-01 00:00:00′;

这么写不报错,但得出结果不准确

方法1:

就是用unix_timestamp函数,将字符型的时间,转成unix时间戳

select * from t1 where unix_timestamp(time1) > unix_timestamp(‘2023-01-01 00:00:00’) and unix_timestamp(time1) < unix_
timestamp(‘2023-12-01 00:00:00”);

方法2:

select * from test where adddate between ‘2023-01-01 00:00:00’ and ‘2023-12-01 00:00:00’;

 

 

作者 admin

百度广告效果展示