mybatis日期查詢

默認查詢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>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章