需求:前端传入开始时间与结束时间作为sql语句的查询条件,数据库为sqlserver,在mybatis中如何写。
代码如下:
<if test="startTime!=null and startTime!=''">
<![CDATA[ and check_time >= convert(datetime,#{startTime},20) ]]>
</if>
<if test="endTime!=null and endTime!=''">
<![CDATA[ and check_time <= convert(datetime,#{endTime},20) ]]>
</if>