Add Business Days to a Date
Tuesday June 30, 2009
Adding methods to existing objects in JavaScript makes even complex tasks simple
You dont need a complicated loop to be able to skip over the weekends when adding or subtracting business days. A half dozen lines of code in a method added to your existing date objects will quickly and efficiently add the functionality without needing a loop.
Add Business Days to a Date


Hello – thanks for this! But it seems using (-5) brings you to the same date…?
i.e.
var aDate = new Date(”7/23/2009″);
aDate.addBusDays(-5);
so…
aDate.getMonth() + 1 + “/” + aDate.getDate() + “/” + aDate.getFullYear() = “7/23/2009″
Oops, a slight error in the script – I have now corrected it.
Ah, I see… I was close; I added the dys < 0 as an else if.
That fixed the 5s starting on a weekday, but when using a Sat or Sun as a start date, the 5s are off…?
i.e.
var aDate = new Date(”7/25/2009″);
aDate.addBusDays(-5) gives you 7/19.
A few flaws in the original script so I have now completely rewritten it.
Thanks for identifying those special cases I missed testing for first time around.