On my project, I created an option for the user to search by date, but in my database, all the inserts are in DateTime format (yyyy-mm-dd h:m:s), while the search is made only with a simple date(yyyy-mm-dd) input. Is there any way I can compare these two values, so the user can find all the inserts on the given date?
CodePudding user response:
you can use eloquent whereDate with format Y-m-d
YourModel::whereDate('created_at','2021-11-24')->get();
or without model
DB::table('your_table')->whereDate('created_at','2021-11-24')->get();