问题记录1
查询所有。列表中2023-04-10有数据
根据区间开始2023-04-10,结束日2023-04-10,没有查出数据,是因为sql在执行是默认将2023-04-10 00:00:00~2023-04-10 00:00:00
解决办法:sql
select count(*) from 表名 as t
where
date_format(t.time,'%Y-%m-%d00:00:00')>=date_format('2023-04-10','%Y-%m-%d00:00:00')
AND
date_format(t.time,'%Y-%m-%d00:00:00')<=date_format('2023-04-10','%Y-%m-%d23:59:59')
mybatis.xml
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
<![CDATA[ and date_format( t.time,'%Y-%m-%d00:00:00') >=date_format(#{startTime},'%Y-%m-%d00:00:00')
and date_format( t.time,'%Y-%m-%d00:00:00') <=date_format(#{endTime},'%Y-%m-%d23:59:59') ]]>
</if>