Calculate difference between 2 dates excluding weekends
I am trying to create a javascript that calculates the total days between Start Date and End Date, while excluding weekends (Saturday and Sunday).
I used the following formula for the date difference:
var sDate1=this.getField("Date2_af_date").value;
var sDate2=this.getField("Date3_af_date").value;
var oDate1 = util.scand("mm/dd/yy", sDate1);
var oDate2 = util.scand("mm/dd/yy", sDate2);
var nDay = 1000 * 60 * 60 * 24;
var eDays=Math.abs(oDate1-oDate2)/nDay+1;
event.value=Math.round(eDays);
Having issues figuring out how to exclude weekends. I'm not familiar with Javascript, so any help is appreciated.