mysql mybatis springMVC

mybatis中时间错误

1、SELECT * from table1 where create_time < '2017-12-18 23:59:59';

2、SELECT * from table1 where create_time < '2017-12-18' '00:00:00'; 平时加参数 

<![CDATA[ AND create_time  < #{endTime} '00:00:00']]> 则效果就是 标红 部分,结果集 和 (1)的结果集相同;最后是查询 某日 23:59:59的数据;和我们的想法不一致,是错误数据

 

3、SELECT * from table1 where create_time < CONCAT('2017-12-18',' 00:00:00');

4、SELECT * from table1 where create_time < '2017-12-18 00:00:00';

5、SELECT * from table1 where create_time < '2017-12-18';

 

一般参数如果是  “年-月-日” 的可以直接 

endTime为 "年-月-日" 等价于 "年-月-日 00:00:00" 
<![CDATA[ AND create_time  < #{endTime}]]>


posted @ 2018-01-17 16:48  he0xff  阅读(116)  评论(0编辑  收藏  举报