Laravel whereDate and whereDay Example

In this tutorial, we will see laravel whereDate and whereDay example. As you all know laravel provides many inbuilt functionalities like query builder, eloquent, etc. So, here we will give you examples of whereDay and WhereDate using the date function in laravel 8.

The whereDate method is used to compare a column's value against a date. whereDate() through we can make conditions like date even column datatype timestamps.

So, Let's see laravel whereDate and whereDay example, date function in laravel 8 also you can use whereDate and whereDay functions in laravel 6, laravel 7 and laravel 8.

WhereDate()

Example :

$birthdate = DB::table('students')
            ->whereDate('bday', '2022-02-06')
            ->get();
dd($birthdate);

 In this example, you will get all results of bday which has a date like 06-02-2022.

Example : 

$birthdate = DB::table('students')
            ->whereDate('bday','<=','2022-02-06')
            ->get();
dd($birthdate);

 

 

whereDay()

The whereDay() method is used to compare a column's value against a specific day of the month, whereDay() through we can get only specific day records from your timestamps column.

 Example :

$birthdate = DB::table('students')
            ->whereDay('bday', '2022-02-06')
            ->get();
dd($birthdate);

In this example, you will get all data which one date day value has 06.

 


You might also like :

techsolutionstuff

Techsolutionstuff | The Complete Guide

I'm a software engineer and the founder of techsolutionstuff.com. Hailing from India, I craft articles, tutorials, tricks, and tips to aid developers. Explore Laravel, PHP, MySQL, jQuery, Bootstrap, Node.js, Vue.js, and AngularJS in our tech stack.

RECOMMENDED POSTS

FEATURE POSTS