mybatis 拼接开始时间和结束时间

<if test="startTime != null">
AND datetime <![CDATA[ >= ]]> ( SELECT DATE_FORMAT( #{startTime}, '%Y-%m-%d 00:00:00' ))
</if>
<if test="endTime != null">
AND datetime <![CDATA[ <= ]]> ( SELECT DATE_FORMAT( #{endTime}, '%Y-%m-%d 23:59:59' ))
</if>

 或者

<if test="createTime_begin != null">
    AND ar.create_time <![CDATA[ >= ]]> DATE_FORMAT(#{createTime_begin}, '%Y-%m-%d 00:00:00')
</if>
<if test="createTime_end != null">
    AND ar.create_time <![CDATA[ <= ]]> DATE_FORMAT(#{createTime_end}, '%Y-%m-%d 23:59:59')
</if>

 

posted @ 2023-11-01 15:47  卡农的忧伤ろ◆  阅读(405)  评论(0)    收藏  举报