mysql日期间隔,php日期间隔

I have students table and they must pay every month, I have start_day and end_day.

For example:

start_day = "2018-01-01";

end_day = "2018-03-30";

I want to send an SMS 3 days before pay day. I don't know how to fetch those dates in this interval.

select user_id from schema.table where end_day between
subdate(current_date, interval 3 day) and subdate(current_date, interval 2 day);

A bad way to do this would be : where date(end_day) = current_date-3

Why I don't prefer the bad way (although it looks simple):

  1. Avoid using functions on joins and where clause. This'll prevent indexes (if any) from being used and will give you nightmares in terms of performance.
  2. Use only the correct operators with intended datatype. - is an arithmetic operator. It's generally not a good practice to use +/- with dates. Use the functions intended to manipulate dates. (subdate, date_add, date_sub etc)