单纯的字符串比较结果不精确.

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') and STR_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';

有些时候%Y-%m-%d %H:%i:%s  这种转换格式并不能得到正确的结果,原因待查

相关文章:

  • 2022-02-02
  • 2022-12-23
  • 2021-12-18
  • 2021-04-30
  • 2021-12-01
  • 2022-12-23
  • 2022-02-09
  • 2022-01-22
猜你喜欢
  • 2022-12-23
  • 2022-01-06
  • 2021-10-19
  • 2022-12-23
  • 2021-06-16
  • 2021-12-19
相关资源
相似解决方案