Laravel Eloquent whereNotBetween() Query Example

Laravel eloquent whereNotBetween query; Through this tutorial, i am going to show you how to use whereNotBetween() query in laravel apps.

The whereNotBetween() will help you to getting data with not between two dates or two values from database in laravel apps.

Laravel Eloquent whereNotBetween() Query Example

Let’s see the below given examples to use of whereNotBetween query with dates or ids in laravel apps:

  • Example 1: Laravel whereNotBetween query With Ids
  • Example 2: Laravel whereNotBetween Date Query

Example 1: Laravel whereNotBetween query With Ids

Let’s see the first example of laravel whereNotBetween query; as follows:

$users = DB::table('users')
                    ->whereNotBetween('votes', [1, 100])
                    ->get();

Example 2: Laravel whereNotBetween Date Query

Let’s see the second example of laravel whereNotBetween date query; as follows:

$users = User::whereNotBetween('created_at', [start_date, end_date])->get();

Note that:- The whereNotBetween method verifies that a column’s value lies outside of two values.

Leave a Comment