Reputation: 662
I have a table called Renewals as follows
id | item_name | next_renewal_date | alert_before_days
2 | Test | 2015-05-25 | 5
6 | Test4 | 2015-05-12 | 2
7 | Test7 | 2015-05-30 | 12
I would like to read the table by alert_before_days. For example, i need the rows with upcoming renewals by its alert_before_days from current date onwards.
I'm using cakephp and tried the following, but nothing works. it only selects the date as 1970-01-01
'conditions'=>array('Renewal.NextRenewalDate <=' => date('Y-m-d', strtotime("+Renewal.AlertBeforeDays days"))
Upvotes: 2
Views: 84
Reputation: 31749
strtotime
will not recognize that expression. Do it with mysql
-
'conditions'=>array(
'Renewal.NextRenewalDate <=' => 'DATE_ADD(NOW() + INTERVAL `Renewal`.`NextRenewalDate` DAY)'
)
Upvotes: 2