主要记住这个sql语句
<select id="selectall" resultType="com.river.entity.Product">
SELECT * FROM product
<where>
<if test="create_time!=null and create_time!=''">
create_time >= #{create_time}
</if>
<if test="update_time!=null and update_time!=''">
AND create_time <= #{update_time}
</if>
<if test="is_activated!=null and is_activated!=''">
AND is_activated=#{is_activated}
</if>
<if test="is_home_page!=null and is_home_page!=''">
AND is_home_page=#{is_home_page}
</if>
<if test="'1'.toString().equals(ti)">
AND to_days(`create_time`) = to_days(now()) //这个是日期代表今天
</if>
<if test="'2'.toString().equals(ti)">
AND to_days(now()) - to_days(`create_time`) <= 1 //这个是日期代表昨天
</if>
<if test="'3'.toString().equals(ti)">
AND DATE_SUB(CURDATE(), INTERVAL 7 DAY) <=create_time //这个是日期代表7天前
</if>
<if test="'4'.toString().equals(ti)">
AND DATE_SUB(CURDATE(), INTERVAL 30 DAY) <=create_time //这个代表30天前
</if>
</where>
ORDER BY id
limit #{pageIndex},#{pageSize}
</select>
1、当前日期
select DATE_SUB(curdate(),INTERVAL 0 DAY) ;
2、明天日期
select DATE_SUB(curdate(),INTERVAL -1 DAY) ;
3、昨天日期
select DATE_SUB(curdate(),INTERVAL 1 DAY) ;
4、前一个小时时间
select date_sub(now(), interval 1 hour);
5、后一个小时时间
select date_sub(now(), interval -1 hour);
6、前30分钟时间
select date_add(now(),interval -30 minute)
7、后30分钟时间
select date_add(now(),interval 30 minute)