is whereBetween in laravel inclusive?

As the other answers here have indicated, yes it is inclusive, but you have to require the time in your parameters in order to make it inclusive - in human terms. My example below sets the time (using Carbon's setTime method) to allow the widest range of chronologic inclusivity.

->whereBetween('start_point_utc', [
          \Carbon\Carbon::createFromFormat('Y-m-d', $startDate)->setTimezone('UTC')->setTime(0, 0, 0)->toDateTimeString(),
          \Carbon\Carbon::createFromFormat('Y-m-d', $endDate)->setTimezone('UTC')->setTime(24, 59, 59)->toDateTimeString()
])

You need to format your created_at to Y-m-d format. Please see the change:

$students = Student::select('id as ID_NO', 'fname as Firstname', 'lname as Lastname', 'created_at')
                                 ->whereBetween(DB::raw('date(created_at)'), 
                                  [Carbon::createFromDate(2016, 5, 12)->toDateString(),
                                   Carbon::createFromDate(2016, 5, 27)->toDateString()])

For others who end up here and want the answer to the question asked (in case it's updated… "Is whereBetween in Laravel inclusive?"):

Yes.


Laravel search between, this means it will get all the rows between 2016-05-12 00:00:00 and 2016-05-27 00:00:00. Your second user is created at 2016-05-27 07:37:45, this is outside the range so Laravel won't fetch it.

Use this and try if this works:

$students = Student::select('id as ID_NO', 'fname as Firstname', 'lname as Lastname', 'created_at')
    ->whereBetween('created_at' [
        Carbon::createFromDate(2016, 5, 12)->toDateString(),
        Carbon::createFromDate(2016, 5, 28)->toDateString()
    ])

Hope this works!