Counts days excluding weekdays and holidays
<p>I know that this question is been asked a lot of time , but please help i am not able to find the solution </p>

<p>with the code below i am able to calculate no of days excluding weekdays</p>

<p>Now i want to also exclude public holidays says for eg 08/15/2012 , 09/12/2012 , 12/20/2012 , please help </p>

<pre><code>function namet()
 {

        var iWeeks, iDateDiff, iAdjust = 0;

        var nodays = document.getElementById("timestamp1").value;


        var nodays1 = document.getElementById("timestamp").value;



        var dDate1 = new Date(nodays1);



        var dDate2 = new Date(nodays);





        if (dDate2 &lt; dDate1) {

            alert("End Date : Enter date more than Start Date ");
        }
        // 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 &gt; 5) &amp;&amp; (iWeekday2 &gt; 5)) iAdjust = 1; // adjustment if both days on weekend
        iWeekday1 = (iWeekday1 &gt; 5) ? 5 : iWeekday1; // only count weekdays
        iWeekday2 = (iWeekday2 &gt; 5) ? 5 : iWeekday2;

        // calculate differnece in weeks (1000mS * 60sec * 60min * 24hrs * 7 days = 604800000)
        iWeeks = Math.floor((dDate2.getTime() - dDate1.getTime()) / 604800000)

        if (iWeekday1 &lt;= iWeekday2) {
          iDateDiff = (iWeeks * 5) + (iWeekday2 - iWeekday1)
        } else {
          iDateDiff = ((iWeeks + 1) * 5) - (iWeekday1 - iWeekday2)
        }

        iDateDiff -= iAdjust // take into account both days on weekend

        var final = (iDateDiff + 1); // add 1 because dates are inclusive

        document.leaveapplication.noofdays3.value = final;
</code></pre>
