mybatis框架支持直接用>=或<=查询日期范围,如:
<if test="startTime != null and startTime != ''">
and timer.create_time >= #{startTime}
<if test="endTime != null and endTime != ''">
and timer.create_time <= #{endTime}
</if>
问题:开始时间和结束时间是同一个日期,就查不出来
解决方法:用DATE_FORMAT转换日期
<if test="ew.plannedStartDate != null">
<![CDATA[ and DATE_FORMAT(planned_start_date, '%Y-%m-%d') >= #{ew.plannedStartDate} ]]>
</if>
<if test="ew.plannedEndDate != null">
<![CDATA[ and DATE_FORMAT(planned_start_date, '%Y-%m-%d') <= #{ew.plannedEndDate} ]]>
</if>
mybatis -plus框架中:
.apply(ObjectUtil.isNotEmpty(dto.getStartTime()),"planned_complete_date >= DATE_FORMAT('"+dto.getStartTime()+"','%Y-%m-%d')")
.apply(ObjectUtil.isNotEmpty(dto.getEndTime()),"planned_complete_date <= DATE_FORMAT('"+dto.getEndTime()+"','%Y-%m-%d')");
因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- dcrkj.com 版权所有 赣ICP备2024042791号-2
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务