I’ve look almost everywhere to find this.
I have the following SQL statement:
SELECT COUNT(*) FROM `job_sheet`
LEFT JOIN deliveries ON job_sheet.job_id=deliveries.jID
WHERE job_sheet.completion=".ORDER_COMPLETE."
AND deliveries.ship_date>job_sheet.delivery_date
Which basically tells me which completed jobs were shipped past their delivery_date (DUE DATE).
However, the true delivery date is in reality 7 business days (holidays don’t matter. basically just skipping the weekend) ahead than what’s in the database.
What I need to be able to do is add 7 days to this section: deliveries.ship_date>job_sheet.delivery_date + 7 business days
My first thought was to use DATEADD() function, however It’s rare that I use it and it’s quite confusing on how to implement it in this situation.
The date is stored as: YYYY-MM-DD
Well, adding 7 days to a date was easy enough with the help I got here. Since I specifically needed to add 7 business days to a certain date, I had to use some PHP along with the rest of my script. I used a custom DateHelper class to do the job.
I combined this class to this:
This will return the number of items that were shipped past their due date with a customizable offset