Changes

Jump to: navigation, search

Counting Business Days between Two Dates

216 bytes added, 14:41, 7 April 2009
no edit summary
To count business days between two dates, the following code can be used in a [[Custom Field Type (103): Special – Browser Script|Special Browser script]] field that will populate a [[Custom FieldType (60): Special – Calculated Value|custom fieldCalculated Value Custom Field]] with the number of business days between two given dates.
<pre>
function busdatediffbus_date_diff()
{
var frm=document.form1forms[0]; var formatstrformatdate="dd/mm/yyyy@dateformat@"; var start=ConvertDateStr(frm.startdate.value,formatstrformatdate); var end=ConvertDateStr(frm.enddate.value,formatstrformatdate); var diff=datediff(start,end, "D"); var i=0; var busdaybusdays=0; for(i=0;i<diff;i++) { var cdate=dateadd(start,'D',i); if(!isHoliday(cdate)) busday busdays++; }frm.cf_56262.value=busday return busdays;
}
busdatediff();
</pre>
In the '''Expression''' section of the [[CategoryCustom Field Type (60):Special – Calculated Value|Calculated Value Custom FieldsField]]you would put the following: bus_date_diff()  [[Category:Applicant TrackingCustom Fields]][[Category:EnhancementsJavaScript Examples]]
0
edits

Navigation menu