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

  • SEARCH
  • Home
  • 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 6161179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:26:06+00:00 2026-05-23T21:26:06+00:00

Excel has NETWORKDAYS() function that find the number of business days between two dates.

  • 0

Excel has NETWORKDAYS() function that find the number of business days between two dates.

Anybody have a similar function for MySQL? Since holidays adds complexity, the solution doesn’t have to deal with holidays.

  • 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-05-23T21:26:07+00:00Added an answer on May 23, 2026 at 9:26 pm

    This expression –

    5 * (DATEDIFF(@E, @S) DIV 7) + MID('0123444401233334012222340111123400012345001234550', 7 * WEEKDAY(@S) + WEEKDAY(@E) + 1, 1)
    

    calculates the number of business days between the start date @S and the end date @E.

    Assumes end date (@E) is not before start date (@S).
    Compatible with DATEDIFF in that the same start date and end date
    gives zero business days.
    Ignores holidays.

    The string of digits is constructed as follows. Create a table of
    start days and end days, the rows must start with monday (WEEKDAY
    0) and the columns must start with Monday as well. Fill in the
    diagonal from top left to bottom right with all 0 (i.e. there are 0
    working days between Monday and Monday, Tuesday and Tuesday, etc.).
    For each day start at the diagonal (must always be 0) and fill in
    the columns to the right, one day at a time. If you land on a
    weekend day (non business day) column, the number of business days
    doesn’t change, it is carried from the left. Otherwise, the number
    of business days increases by one. When you reach the end of the
    row loop back to the start of the same row and continue until you
    reach the diagonal again. Then go on to the next row.

    E.g. Assuming Saturday and Sunday are not business days –

     | M T W T F S S
    -|--------------
    M| 0 1 2 3 4 4 4
    T| 4 0 1 2 3 3 3
    W| 3 4 0 1 2 2 2
    T| 2 3 4 0 1 1 1
    F| 1 2 3 4 0 0 0
    S| 1 2 3 4 5 0 0
    S| 1 2 3 4 5 5 0
    

    Then concatenate the 49 values in the table into the string.

    Please let me know if you find any bugs.

    -Edit
    improved table:

     | M T W T F S S
    -|--------------
    M| 0 1 2 3 4 4 4
    T| 4 0 1 2 3 3 3
    W| 3 4 0 1 2 2 2
    T| 2 3 4 0 1 1 1
    F| 1 2 3 4 0 0 0
    S| 0 1 2 3 4 0 0
    S| 0 1 2 3 4 4 0
    

    improved string: ‘0123444401233334012222340111123400001234000123440’

    improved expression:

    5 * (DATEDIFF(@E, @S) DIV 7) + MID('0123444401233334012222340111123400001234000123440', 7 * WEEKDAY(@S) + WEEKDAY(@E) + 1, 1)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have an existing Traceability Matrix in Excel that has columns like: Project Business
I have an Excel file that has a bunch of VBA and macro code
So I have an excel workbook that has a nice global map of shaperange
Excel has a lookup function that finds a specified value in a row or
I have a table (it was imported from Excel) that has a wide variety
I have an Excel document that has a single column of strings (around 400
I have an Excel worksheet that has the following macro. I'd like to loop
I have an excel file that has conditional formating set up to put a
I am sure somebody has worked out to simulate Excel networkdays function in other
I have a flat file source from Excel that has a structure like this:

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.