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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:48:55+00:00 2026-05-16T14:48:55+00:00

Hi want to get a date list between start date and end date. For

  • 0

Hi want to get a date list between start date and end date. For example start date is 27-08-2010 and end date is 31-08-2010. So the date list is 27-08-2010,30-08-2010 and 31-08-2010. 29-08-2010 and 30-08-2010 will be ignore because it is in the weekend. I attach the picture for more clearer explanation. How to achieve this using javascript or jquery? I only want to get the list of date, for the business day calculation already done.

alt text

  • 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-16T14:48:56+00:00Added an answer on May 16, 2026 at 2:48 pm

    First of all, we can disable in the datepickers the holidays and the weekends, for that we’ll be setting it like this in each datepicker component:

    Disable weekends and holidays from DatePicker

    var disabledDays = ["10-22-2010","8-16-2010"];
    $("#startDate").datepicker({
        constrainInput: true,
    beforeShowDay: noWeekendsOrHolidays
    });
    
    function nationalDays(date) {
        var m = date.getMonth(), d = date.getDate(), y = date.getFullYear();
        for (i = 0; i < disabledDays.length; i++) {
            if($.inArray((m+1) + '-' + d + '-' + y,disabledDays) != -1 || new Date() > date) {
                return [false];
            }
        }
        return [true];
    }
    function noWeekendsOrHolidays(date) {
        var noWeekend = jQuery.datepicker.noWeekends(date);
        return noWeekend[0] ? nationalDays(date) : noWeekend;
    }
    

    Now that we have the behavior to not let users select weekends or holidays as startdate or enddates we continue, calculating the total days between those dates:

    Calculate Business Dates between two dates

    as Find day difference between two dates (excluding weekend days) we have this function to calculate business days between dates:

    function calcBusinessDays(dDate1, dDate2) { // input given as Date objects
        var iWeeks, iDateDiff, iAdjust = 0;
        if (dDate2 < dDate1) return -1; // error code if dates transposed
        var iWeekday1 = dDate1.getDay(); // day of week
        var iWeekday2 = dDate2.getDay();
        iWeekday1 = (iWeekday1 == 0) ? 7 : iWeekday1; // change Sunday from 0 to 7
        iWeekday2 = (iWeekday2 == 0) ? 7 : iWeekday2;
        if ((iWeekday1 > 5) && (iWeekday2 > 5)) iAdjust = 1; // adjustment if both days on weekend
        iWeekday1 = (iWeekday1 > 5) ? 5 : iWeekday1; // only count weekdays
        iWeekday2 = (iWeekday2 > 5) ? 5 : iWeekday2;
    
        // calculate differnece in weeks (1000mS * 60sec * 60min * 24hrs * 7 days = 604800000)
        iWeeks = Math.floor((dDate2.getTime() - dDate1.getTime()) / 604800000)
    
        if (iWeekday1 <= iWeekday2) {
          iDateDiff = (iWeeks * 5) + (iWeekday2 - iWeekday1)
        } else {
          iDateDiff = ((iWeeks + 1) * 5) - (iWeekday1 - iWeekday2)
        }
    
        iDateDiff -= iAdjust // take into account both days on weekend
    
        return (iDateDiff + 1); // add 1 because dates are inclusive
    }
    

    Count down Holidays

    I’m right now in a hurry, what you need to do now is --iDateDiff (just before the return) for every date in disabledDays that is between dDate1 and dDate2.

    How will you accomplish that?… You will iterate over the disabledDays array and convert/parse it to the Date Object and evaluate like:

    var holiDay = Date.parse(iteratedDate);
    if((holiDay >= dDate1 && holiDay <= dDate2)) {
        --iDateDiff
    }
    

    I hope i’ve helped you…


    EDITED:

    Sorry, misunderstood the question, try this:

    var Weekday = new Array("Sun","Mon","Tue","Wed","Thuy","Fri","Sat");
    while (startDate<=endDate)
      {
      var weekDay = startDate.getDay();
      if (weekDay < 6 && weekDay > 0) {
        var month = startDate.getMonth()+1;
        if( month <= 9 ) { month = "0"+month; }
        var day = startDate.getDate();
        if( day <= 9 ) { day = "0"+day; }
        document.write(day+"/"+month+"/"+startDate.getFullYear() + " ("+Weekday[weekDay]+")<br />");
      }
      startDate.setDate(startDate.getDate()+1)
    
      }
    

    Live DEMO

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

Sidebar

Related Questions

I want to get the list of sales for each month ordered by product.
Don't think this is a repost, difficult to search for the word between because
I want to create a What's New section that lists all of the database
Initial conditions: DateTime moment string key double value somewhere across the code i want
I have 2 list objects, one is just a list of ints, the other
I wrote a little powershell function that executes Get-EventLog against remote servers. On some
I'm stumped on this one, or just to late at night to be thinking
I'm new to lambda expressions, and just ran into something I don't understand. I
The project I have been given is to store and retrieve unstructured data from
Having a bit of an issue accessing dynamically added DIV's immediately after they've been

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.