How do I do something like the following
SELECT ADDDATE(t_invoice.last_bill_date, INTERVAL t_invoice.interval t_invoice.interval_unit)
FROM t_invoice
...where the column t_invoice.last_bill_date is a date, t_invoice.interval is an integer and t_invoice.interval_unit is a string.
What I like about the ADDDATE() function is that if I write a
SELECT ADDDATE('2010-01-31', INTERVAL 1 MONTH)
It conveniently returns the last day of February - 2010-02-28. So it knows that 1 MONTH means 28 days for Feb (29 on leap year), 31 if odd number month, 30 if even number month. I would like to preserve this feature in my query.
Basically, I want to determine a person's next bill date based on his desired billing frequency. Is there a better way to achieve this?