在项目中查询时间段的sql语句(时间类型为varchar)(数据库中的时间类型):
<if test="beginTime!=null and beginTime!=''">
<![CDATA[ and DATE_FORMAT(tr.add_time, '%Y-%m-%d')>= DATE_FORMAT(#{beginTime}, '%Y-%m-%d') ]]> </if>
<if test="endTime!=null and endTime!=''">
<![CDATA[ and DATE_FORMAT(tr.add_time, '%Y-%m-%d') <= DATE_FORMAT(#{endTime}, '%Y-%m-%d') ]]> </if>
<if test="beginTime!=null and beginTime!=''"> AND tm.add_time>=#{beginTime} </if>
<if test="endTime!=null and endTime!=''"> AND tm.add_time <=#{endTime} </if>
<if test="endDate != null" >
and lt.create_time <= DATE_ADD(#{endDate, jdbcType=TIMESTAMP}, INTERVAL 1 DAY)
</if>
<if test="startDate != null" >
and lt.create_time >= #{startDate, jdbcType=TIMESTAMP}
</if>
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30180323/viewspace-2149089/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/30180323/viewspace-2149089/