mybatis日期查询

来源:互联网 发布:人工智能技术 知乎 编辑:程序博客网 时间:2024/05/22 10:25

默认查询7天的数据

<if test="startDate != null and startDate !='' ">            <![CDATA[AND a.use_date >= #{startDate}]]>        </if>        <if test="endDate != null and endDate !='' ">            <![CDATA[AND a.use_date < #{endDate}]]>        </if>         <if test='startDate == null and endDate == null' >            AND DATE_SUB(CURDATE(),INTERVAL 7 DAY) &lt;= a.use_date        </if>

默认查询昨天的数据

<if test='startDate == null and endDate == null' >            AND TO_DAYS( NOW( ) ) - TO_DAYS( a.dept_kpi_date) = 1        </if>

参考:

http://www.cnblogs.com/qinweizhi/p/5918048.html

if判断参数等于某个值

<if test=' type == "1"'>....</if>
原创粉丝点击