单纯的字符串比较结果不精确.
select * from 表明 where times> ‘2088/12/8 10:02:40‘
(×)
转换函数如下(数据库为varchar):
select * from h_hotelcontext where now() between STR_TO_DATE(Start_time,‘%Y-%m-%d %H:%i:%s‘) andSTR_TO_DATE(End_time,‘%Y-%m-%d %H:%i:%s‘);
select max(addtime) from student where stuid=‘9‘;(×)
select max(STR_TO_DATE( addtime,‘%Y/%m/%d %H:%i:%s‘)) from student where stuid=‘9‘;
时间: 2024-10-21 15:51:13