Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9021885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:21:50+00:00 2026-06-16T05:21:50+00:00

I’ve look almost everywhere to find this. I have the following SQL statement: SELECT

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T05:21:53+00:00Added an answer on June 16, 2026 at 5:21 am

    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.

    class DateHelper {
    
        var $holidays = array("2010-07-04", "2010-09-06", "2010-09-23", "2010-10-11", "2010-11-01", "2010-11-11",  "2010-11-25", "2010-12-25");
        const oneday = 86400; 
        const weekend = 172800; 
    
        function addBusinessDays($start_date, $business_days)
        {
    
            if (date('N', $start_date) == 6)
            { // If start date is on Saturday
                $new_start_date = $start_date + self::weekend;
            } 
            elseif (date('N', $start_date) == 7)
            { // If start date is on Sunday
                $new_start_date = $start_date + self::oneday;
            } 
            else 
            {
                $new_start_date = $start_date;
            }
    
            $due_date = $new_start_date + $business_days * self::oneday;
            $due_date += floor($business_days / 5) * self::weekend;
    
            if (($business_days % 5) + date('N', $new_start_date) >= 6)
            {
                $due_date += self::weekend; // Add 2 days to compensate for the weekend
            }
    
            foreach($this->holidays as $holiday)
            {
                $time_stamp = strtotime($holiday);
    
                // If the holiday falls between the start date and end date
                // and is on a weekday
                // Or if $new_start_date is on a holiday
                if (($start_date <= $time_stamp && $time_stamp <= $due_date && date("N", $time_stamp) < 6) || date("Y-m-d", $new_start_date) == $holiday)
                {
                    $due_date += self::oneday;
                    if (date('N', $due_date) >= 6)
                    {
                        // If due date on Saturday or Sunday
                        $due_date += self::weekend;
                    }
                }
            }
    
            return $due_date;
        }
    }
    

    I combined this class to this:

    //jobs that were shipped past their due date
    public function totalShippedLate($offset = 7)
    {
        $sql = mysql_query("SELECT deliveries.ship_date, job_sheet.delivery_date, deliveries.qty_shipped FROM `job_sheet` LEFT JOIN deliveries ON job_sheet.job_id=deliveries.jID WHERE job_sheet.completion=".jobInfo::ORDER_COMPLETE."") or die(mysql_error());
        $x = 0; // number of items shipped
        while($data = mysql_fetch_array($sql))
        {
            $date = new DateHelper();
            $offset_date = date("Y-m-d", $date->addBusinessDays(strtotime($data['delivery_date']), $offset));
            if($data['ship_date']>$offset_date)
            {
                $x += $data['qty_shipped']; 
            }
        }
        return $x;  
    }
    

    This will return the number of items that were shipped past their due date with a customizable offset

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
This could be a duplicate question, but I have no idea what search terms
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I have a view passing on information from a database: def serve_article(request, id): served_article

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.