Laravel whereday query builder example; In this tutorial, you will learn how to use whereDay query in laravel. We can use laravel whereDay eloquent query easy and simple way.
The whereDay method may be used to compare a column’s value against a specific day of the month. If you want to get every month 30th day records, you can see bellow example with output. You can use whereDay quesy in laravel 5, laravel 6, laravel 7, laravel 8 or laravel 9 version.
Example 1:
use App\Models\User;
class UserController extends Controller
{
public function index()
{
$users = User::whereDay('created_at', '=', '30')
->get();
dd($users);
}
}
Example 2:
use App\Models\User;
class UserController extends Controller
{
public function index()
{
$users = User::whereDay('created_at', '>=', '10')
->get();
dd($users);
}
}
Hope these laravel where day query builder examples help you.