I will show you example of get records between two dates from database using laravel Eloquent whereBetween method. whereBetween helps to get data between 2 dates from database. here also show you example for retrieve records using where between two columns of database table.
Here i am getting records from users table and get all data of given $start and $end date between records. So you can see following simple example and understand how it is works.
You can also get records from where between two columns. So i give you both example are bellow you can see both example as bellow:
Where Between Two Dates:
$users = User::select("users.*")
->whereBetween('created', ['2018-02-01', '2018-02-10'])
->get();
dd($users);
Where Between Two Columns:
$users = User::select("users.*")
->whereRaw('? between start_date and end_date', [date('Y-m-d')])
->get();
dd($users);
I hope you found best solution.....
Do you like below Tutorials ?
- Angular Use CKEditor Example Tutorial
- How to Use Multiple Select Dropdown in Laravel?
- Angular 9 Image Upload with Crop Example
- Files Upload on Button Click in PHP Dropzone Example
- PHP Dropzone Allow only One File to Upload Example
- PHP Dropzone Allow only Images to Upload Example
- PHP Dropzone Delete Uploaded File Example
- Livewire CRUD Laravel 7 Example