0

I need to change the below MySQL code to laravel format using where, between and like operators together:

select count(id) from tbl1 
where created_at BETWEEN 
   '2018-12-10%' AND '2018-12-12%' 
Ismael Padilla
  • 5,246
  • 4
  • 23
  • 35

2 Answers2

2

I found the answer as below:

\DB::table('tbl1')->whereBetween('created_at',[$sdate.'%', $enddate.'%'])->count();
0

If you're using a Model you could use the whereBetween method, take a look at the following example: User::query()->whereBetween('created_at', [$start, $end])->count();