In this post, We will see Laravel query builder methods. I will explain how to use Laravel whereDate() and whereDay().
Let?s start with how to use whereDate() and whereDay() Laravel Query Builder methods.
Below we will see one by one method with example and understand the how this two Laravel query builder functions works.
This is the short guide of whereDate() and whereDay() Laravel Query Builder methods.

whereDate() Example

Now, we will see how to use whereDate() example.

1. Example 1
Let?s take and example of Employee table, we need to find the list of employee who joined on 2021-10-01 this particular date, for that we need to use whereDate() methods, below example will give you the demonstration.

$employeeLists = DB::table('employee')
                  ->whereDate('joining_date', '2021-10-01')
                  ->get();

In the above example, you will get all employee who joined on 2021-10-01.

2. Example 2

Now we will take second example of whereDate() methods, In the second example we will find the list of employee who joined in 2021 year.

$employeeLists = DB::table('employee')
                  ->whereDate('joining_date', '>=','2021-01-01')
                  ->get();

In the above example, you will get all employee who joined in 2021 year.

whereDay() Example

Now, we will see how to use whereDay() example.
We will use same employee table for this method also, if we want to find the list of employee who joined on 01 first day of every month then we have to use whereDay() method.
Below example will give the demonstration.

$employeeLists = DB::table('employee')
                     ->whereDay('joining_date', '01')
                     ->get();

I hope you will like the content and it will help you to learn Laravel whereDate and whereDay Example
If you like this content, do share.


Recommended Posts

View All

TOP PROGRAMMING LANGUAGES TO GET A JOB AT GOOGLE, MICROSOFT AND FACEBOOK


It's an available fact that if you want to work at the big tech companies, you need to know how to make an impression.

How To Integrate Google Maps in Laravel


A number of ways are available through the Google Maps JavaScript API to build maps for web applications.

Laravel Eloquent Query - Laravel whereKey method


We'll look at the whereKey method in Laravel Eloquent in this post. whereKey is an extremely easy-to-use tool with a lot of potential.

How To Use WYSIHTML5 Editor In Laravel 9?


wysihtml5 editor example, laravel wysihtml5 editor example, wysihtml5 laravel, wysihtml5 editor example in laravel, wysihtml5 with laravel, wysihtml5...

Crop Image Before Upload Using Croppie.js in Laravel 9


Using Laravel 9, crop an image before uploading it using Croppie.js. Before uploading an image, Laravel uses Ajax to crop it with croppie. Cropping an...