Hi all, I'm working on something for my job that requires a script that will display a date x number of business days in the past. (Actually two scripts - one for 3 business days ago, and one for 8 business days ago - but I just need to get one of them done, and I'll be set!!) I found a script online that will count days in the FUTURE and skip weekends, however, when I tried to modify it to count backwards, it no longer skips weekend days. Can someone take a look at my Franken-Script and let me know if I forgot to change a setting or something that will allow it to count backwards and NOT include weekend days? It displays in the format I want already, but it can look as pretty as it wants - it won't help if the date is wrong!

For example, the script below, when run today (Feb 2), returns January 25 - 8 days ago - instead of January 23 - 8 BUSINESS days ago.


<script language=JavaScript>
function getNextBusinessDay() {
return getDeliveryDateObj(-8);
}

function getDeliveryDateObj(businessDaysLeftForDelivery) {
var now = new Date();
var dayOfTheWeek = now.getDay();
var calendarDays = businessDaysLeftForDelivery;
var deliveryDay = dayOfTheWeek + businessDaysLeftForDelivery;
if (deliveryDay >= 6) {
businessDaysLeftForDelivery -= 6 - dayOfTheWeek; //deduct this-week days
calendarDays += 2; //count this coming weekend
deliveryWeeks = Math.floor(businessDaysLeftForDelivery / 5); //how many whole weeks?
calendarDays += deliveryWeeks * 2; //two days per weekend per week
}
now.setTime(now.getTime() + calendarDays * 24 * 60 * 60 * 1000);
return now;
}


var now = getNextBusinessDay();

var months = new Array('January','February','March','April','May','June','July','August','September','October','Novem ber','December');

var date = ((now.getDate()<10)? "0" : "")+ now.getDate();

daymonth = months[now.getMonth()]
wkday = date

document.write("<p align=center><b><font face=Verdana size=1 color=blue>");
document.write(daymonth);
document.write("</font><br><font face=Verdana size=6 color=blue>");
document.write(wkday);
document.write("</font></b></p>");
</script>