How to convert below query into Laravel equivalent query builder
SELECT * FROM `table_name` WHERE '03-05-2017 09:30' BETWEEN `start_date` AND `end_date` AND `who_should`='VV000'
I tried using whereBetween but not working as expected.
$date = new Carbon\Carbon('03-05-2017 09:30');
$date_string=$date->toDateTimeString();
$data_set = DB::table('table_name')
->select(DB::raw('*'))
->where('start_date', '<', $date_string )
->where('end_date', '>', $date_string )
->where('who_should','=','VV000')
->get();
Try above code
column_name BETWEEN '03-05-2017 09:30' AND '10-05-2017 09:30'is the format I am unable to understand the Logic where you are checking the constant value...where > and <or you can add raw where clause inwhereRawalso.