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 8093725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:33:46+00:00 2026-06-05T20:33:46+00:00

We have a from date and To date in Table fields. We are getting

  • 0

We have a from date and To date in Table fields.

We are getting an int value(Tot days) by using minus of To date from From Date.

Totdays = Todate – FromDate;

Up to here it is fine but problem arises if we have weekdays in the range between from date to Todate.

How to write X++ code to deduct weekdays in the range and get TotDays based on workingdays.

  • 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-05T20:33:47+00:00Added an answer on June 5, 2026 at 8:33 pm

    Days between two dates not counting Saturday and Sunday:

    static void WorkDayDiff(Args _args)
    {
        int i;
        Days workDayDiff(date d1, date d2)
        {
            Days y1 = dayofwk(d1);          // Day of week 1
            Days y2 = dayofwk(d2);          // Day of week 2
            date t1 = d1 - y1;              // Sunday before d1
            date t2 = d2 - y2;              // Sunday before d2
            Days y3 = (t2 - t1) div 7 * 5;  // Work days between Sundays
            Days y4 = min(y1-1,5);          // Work days before d1
            Days y5 = min(y2,5);            // Work days after t2
            return y3 - y4 + y5 - 1;        // Work days between d1 and d2
        }
        ;
        setprefix(strFmt("Today %1 %2", today(), dayname(dayofwk(today()))));
        for (i = -10; i <= 10; i++)
            info(strFmt("Diff %1 %2 = %3", today()+i, dayname(dayofwk(today()+i)), int2str(workDayDiff(today(), today() + i))));
    }
    

    The count is negative if d2 is less than d1, but it may not be what you expect.

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

Sidebar

Related Questions

I have a table containing 2 date fields and an identifier (id, fromdate and
I have a simple mysql table called messages with the following fields: ID(int) MESSAGE(varchar)
Hi i have a table with the following fields 'Site Code' 'Date' 'Hour' 'Quantity'
I have table consisting of these fields: id | date_from | date_to | price
I have table consisting of these fields: id | date_from | date_to | price
I have following SQL statementL: select DATE(bla), count(*) from tableA group by DATE(bla) UNION
I have a date field in the database table of this format 2012-02-1.i need
I Have recordset rc1 that reads values from txt file. The fields are rtn
I have a website where I display information from a mysql table such as
I have a table, user_quotes , with the fields quotes_id , quotes_user , quotes_desc

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.