当前位置: 代码迷 >> 综合 >> sqlserver数据库,mybatis中时间范围查询的应用。
  详细解决方案

sqlserver数据库,mybatis中时间范围查询的应用。

热度:53   发布时间:2024-03-06 17:22:05.0

需求:前端传入开始时间与结束时间作为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>

 

  相关解决方案