Lijesh Shakya
Lijesh Shakya

Reputation: 2540

WhereBetween function in not working properly Laravel 5.0

$dt = \Carbon::now();
$tomorrow = Carbon::tomorrow();
$yesterday = Carbon::yesterday();
$data = $this->model->select('id', 'description')
 ->whereBetween($dt, array($yesterday, $tomorrow))->get();

It is returning an error saying "An error occurred in database operation."

Upvotes: 0

Views: 40

Answers (1)

Sonali Bhat
Sonali Bhat

Reputation: 86

In the wherebetween clause the first argument should be table column field, which you are trying to compare. For example:

$data = $this->model->select('id', 'description')
 ->whereBetween('created_date', array($yesterday, $tomorrow))->get();

Upvotes: 1

Related Questions