I need help with mysql and date_sub (). I have a table call function
Activity(id,deadline,alert)
Activity(1,'2011-04-18','1 DAY');
Activity(2,'2011-04-13','1 MONTH');
Each line in has a “warning”, this field indicates how time to the deadline the event should report.
for instance
On 2011-04-17 I have to report the activity with 'id' 1
On 2011-03-14 I have to report the activity with 'id' 2
I am trying to use functions date_sub(), but I cannot use a field as parameters of this function. Any idea how to fix this?
SELECT *
FROM `activities`
WHERE date_sub(`deadline`, INTERVAL alert) >= CURDATE();
source
share