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 9 HttpClient Request with RxJS Observable Example
- How to Create Routing Module in Angular 9?
- How to Create Custom Directive in Angular 9?
- Print Iframe Content using JQuery Example
- Allow Only Numeric Values in Textbox using JQuery
- Codeigniter Confirmation Box Before Delete Item Example
- How to Use Sweet Alert in Codeigniter?
- Disable F5 Key And Browser Refresh Using Javascript