java web 项目,用的 springboot 构建的,数据库是 mysql
写了个 select 语句,控制台输出的 sql 如下
select id, duty_type, date, tips from schedule s where s.date BETWEEN ? AND ?
2019-04-30 10:43:17.226 DEBUG 3148 --- [nio-7777-exec-9] c.i.i.dao.ScheduleMapper.selectByDate : ==> Parameters: 2019-02-13(Date), 2019-04-23(Date)
然后在 navicat 中输入查询的 sql 如下
select id, duty_type, date, tips from schedule s where s.date BETWEEN '2019-04-10' AND '2019-04-23' ;
在我看来是一模一样的,但是实际上通过 mybatis 查到的结果相当于直接查询 between '2019-04-10' AND
'2019-04-22' 也就是说要少了一天
数据库中 date 的数据类型也是 date,这个问题很让我困惑,不知道有没有大佬告知一下。