I am using Laravel 5, and I would like get rows between two dates in my database (SQLite).
I am using this command:
$trackers = Tracker::whereBetween('detect_at', [$date1, $date2])->where("serial", "uhu")->get();
But I get no response.
Entire request:
$date1 = "2015-07-13 03:53:38";
$date2 = "2015-07-13 03:58:36";
$trackers = Tracker::whereBetween('detect_at', [$date1, $date2])->where("serial", "uhu")->get();
Here is an example of one row in my database:
id serial latitude longitude altitude accuracy detect_at created_at updated_at
728 uhu 48.0491 -1.74138 0 20 2015-07-13 03:54:38 2015-07-02 13:40:15 2015-07-02 13:40:15
Wrap the dates in Carbon objects:
// At top of file
use Carbon\Carbon;
$trackers = Tracker
::whereBetween('detect_at', [new Carbon($date1), new Carbon($date2)])
->where("serial", "uhu")
->get();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With