Laravel whereDate and whereDay Example

In this small tutorial we will see laravel whereDate and whereDay example, as you all know laravel provide many inbuilt functionalities like query builder, eloquent etc.

So, here i will give you example of whereDay and WhereDate using date function in laravel 8.

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

WhereDate()

Example-1 :

$birthdate = DB::table('students')
->whereDate('bday', '2021-01-01')
->get();
dd($birthdate);

In this example you will get all result of bday which one have date like 01–01–2021.

Example-2 :

$birthdate = DB::table('students')
->whereDate('bday','<=','2021-01-01')
->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', '2021-01-01')
->get();
dd($birthdate);

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

Thanks for reading…!!
Don’t forgot to like, share and claps.