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
try this
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> DATE_ADD(`job_deliveries.ship_date` , INTERVAL 7 DAY)
REFRENCE OF ADD_DATE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With