Calculate No Of Days Excluding Weekends and Holidays
Dear All
I am able to calculate no od days excluding weekdays with the code below ,
Can some one please help the also exclude the public holidays what code i need to add to below code that will exclude the public holidays and give final result , please help
<script type="text/javascript">
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 < 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 > 5) && (iWeekday2 > 5)) iAdjust = 1; // adjustment if both days on weekend
iWeekday1 = (iWeekday1 > 5) ? 5 : iWeekday1; // only count weekdays
iWeekday2 = (iWeekday2 > 5) ? 5 : iWeekday2;
Bookmarks