jeudi 6 décembre 2018

Query between dates or matching date ranges in laravel and eloquent

I'm creating a page that displays the ongoing service orders of the current week. I can successfully query the database for tasks that happen between two dates, but the problem I am facing is this.

Let's say the current week starts on the 02/12 and ends on 08/12, and I have a service order that goes from 01/12 to 10/12, it surpasses the current week date range by one day in the start date and two days on the end date.

If I was able to make myself clear, How do I go about querying the database in order to retrieve service orders that are happening during the current week but the start and end dates that are beyond the current week range?

Heres the code I am using to query the database for SOs between dates:

->whereBetween("service_orders.initial_date", array($initialDate, $finalDate))
->orWhereBetween("service_orders.final_date", array($initialDate, $finalDate))
->where("service_orders.completed_date", "=", null)
->get();

Thanks for your help!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire