需求: 如快到一年时,提前一个月进行提醒。
伪代码:
create_date + x = expire_date // 过期的肯定不用管
expire_date - m = tip_date // tip_date 就是提示开始的时间。
// 所以这个sql大概应该这么写
create_date between add_month(add_months(create_date,12),-1) add_months(create_date,12);
inv_date +360 = expire 也就是end
expire -30天= tip 也就是start
条件:inv_date between tip and expire
用月来大致判断:
expire= add_months(inv_date,12)
tip= add_months(add_months(inv_date,12),-1)
实际条件为: inv_date between add_months(inv_date,12) and add_months(add_months(inv_date,12),-1)
如果要360天逾期,30天提前提醒:
t.inv_date between sysdate-360 and sysdate-330
如果要查看日期范围:
select sysdate-360 start_date,sysdate-330 end_date from dual;