SELECT * FROM mytable WHERE created_date
BETWEEN CURDATE() - INTERVAL 90 DAY AND CURDATE();
How can I write this query in Laravel?
Laravel have a good solution for this and it is whereBetween see that here https://laravel.com/docs/5.6/queries
The following query gives you records that has date between now and date 90 days back:
$now = date('Y-m-d'); // now
$old = date('Y-m-d', strtotime('-90 days')); // 90 days back
$records = DB::table('mytable')->where('created_date', '>=', $old)
->where('created_date', '<=', $now)
->get();
You should read Laravel Docs: https://laravel.com/docs/5.1/queries#where-clauses
Hope it helps.