Counting Business Days between Two Dates

From SmartWiki
Revision as of 14:00, 24 March 2009 by Julia Decker (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

To count business days between two dates, the following code can be used in a Special Browser script field that will populate a custom field with the number of business days between two given dates.


function busdatediff()
{
var frm=document.form1;
var formatstr="dd/mm/yyyy";
var start=ConvertDateStr(frm.startdate.value,formatstr);
var end=ConvertDateStr(frm.enddate.value,formatstr);
var diff=datediff(start,end, "D");
var i=0;
var busday=0;
for(i=0;i<diff;i++)
{
   var cdate=dateadd(start,'D',i);
   if(!isHoliday(cdate))
     busday++;
}
frm.cf_56262.value=busday;
}
busdatediff();