Reputation: 49
I have a table: id, name, date, warning_days
I'm trying to query the table like this:
$result= Table::find()->where([
'<=', 'date', date('Y-m-d', strtotime('+ '.'warning_days'.' days'))])->all();
I'm fiddling with the code, but can't seem to find a way... Can somebody, point me in the right direction? Thanks in advance, regards, Rui
Upvotes: 0
Views: 118
Reputation: 133360
the simplest way is the use of where method in literal format based on date_add( )
$result= Table::find()
->where( 'date <= date_add( date, INTERVAL warning_day DAY)')
->all();
or you can use operator format
$result= Table::find()
->where( ['<= ', date , 'date_add( date, INTERVAL warning_day DAY)'])
->all();
Upvotes: 1