Laravel Eloquent whereNotBetween() Query Example
This tutorial will give you example of laravel where not between eloquent. we will help you to give example of laravel eloquent whereNotBetween. you will learn laravel eloquent whereNotBetween dates. Here you will learn laravel whereNotBetween dates example. Alright, let’s dive into the steps.
whereNotBetween() will help you to getting data with not between two dates or two values from database in laravel 6, laravel 7, laravel 8 and laravel 9 application.
In this example i will give you very simple example of how to use whereNotBetween in laravel application. you can easily use it with laravel 6 and laravel 7 application.
So, let's see bellow examples that will help you how to use whereNotBetween() eloquent query in laravel.
Example 1:
SQL Query:
select * from `users`
where `points` not between ? and ?
Laravel Query:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\User;
class UserController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$users = User::select("*")
->whereNotBetween('points', [1, 100])
->get();
dd($users);
}
}
Example 2:
SQL Query:
select * from `users`
where `created_at` not between ? and ?
Laravel Query:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\User;
use Carbon\Carbon;
class UserController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$start = Carbon::now()->subDays(30);
$end = Carbon::now();
$users = User::select("*")
->whereNotBetween('created_at', [$start, $end])
->get();
dd($users);
}
}
I hope it can help you...

Hardik Savani
I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- Laravel Eloquent whereRaw Condition Example
- Laravel Eloquent Where Query Examples
- Laravel orWhere Condition using Eloquent Query
- Laravel Multiple Where Condition Example
- Laravel WhereNotIn Query Example
- Laravel Eager Loading with Condition Relationship Example
- Laravel Eager Loading with Count Relationship Example
- Laravel Many to Many Eloquent Relationship Tutorial
- Laravel - whereIn and whereNotIn with subquery example using query builder
- Laravel - Where Condition with Two Columns Example
- Laravel Where Clause with date_format() Example
- Laravel Like Query Example using Eloquent Where Clause