Answer the question
In order to leave comments, you need to log in
How to organize a query with a date range in yii2?
You need to sample over a period.
I do this but it doesn't work
$leftDate = '2016-01-01';
$rightDate = date('Y-m-d');
$trips = Trip::find()
->joinWith(['idDrivers'])
->where('Date_start >= :left and Date_end <= :right', [':left' => $leftDate, ':right' => $rightDate])
->all();
Answer the question
In order to leave comments, you need to log in
$leftDate = '2016-01-01';
$rightDate = date('Y-m-d');
$trips = Trip::find()
->joinWith(['idDrivers'])
->where('DATE(Date_start) >= :left and DATE(Date_end) <= :right', [':left' => $leftDate, ':right' => $rightDate])
->all();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question