DEV Community


Laravel whereBetween Query Example

I am Laravel Developer. I have good knowledge of JavaScript, JQuery, Bootstrap and REST API.
Originally published at ・1 min read

In this post we will see laravel whereBetween query example. SQL provides many different type of method or query to get filtered data from database. So, in this post we will learn laravel orWhereBetween query builder example.

Here i will give you code of laravel wherebetween dates example, in below code I have added laravel wherebetween with orwherebetween SQL query as well as Laravel query.

Example of whereBetween() condition in laravel

$students = DB::table('Register')
           ->whereBetween('RollNo', [1, 50])
Enter fullscreen mode Exit fullscreen mode

Now I will show you example of whereBetween() query in laravel 6/7/8 and how to write whereBetween() condition in laravel. So first we will see SQL query for better understanding.

SQL OR Example

select * from `Register` where `rollno` between ? and ?
Enter fullscreen mode Exit fullscreen mode

Here we will see another example to get all records between two dates using wherebetween in laravel


namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Register;
use Carbon\Carbon;

class RegisterController extends Controller
    public function index(Request $request)
      $names = Register::whereBetween

Enter fullscreen mode Exit fullscreen mode

Read Also : Laravel AJAX CRUD example

Read Also : Import Export CSV/EXCEL File In Laravel

Thanks for the reading...!!

Discussion (0)