- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2019 12:54 AM
I want to get number of working days between start date and end date in a business rule.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2019 08:38 AM
add +1 to business_days. That should solve the issue
Use the below logic to add 1
var dc = new DurationCalculator();
dc.setSchedule('eb65c2250fc76340e1f30dbce1050ee2', 'Los Angeles'); // Schedule sys_id and system time zone
var dur = dc.calcScheduleDuration(start, end);
var business_days = dur/(60*60*9); // Update the t
var gdt = new GlideDateTime(end);
var day_of_month = gdt.getDayOfWeekUTC();
if(day_of_month < 6)
business_days += 1;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2019 02:02 AM
Use date difference script for that two date fields

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2019 02:08 AM
Try below script:
Script Include:
var calculatedates = Class.create();
calculatedates.prototype = Object.extendsObject(AbstractAjaxProcessor, {
datediff1:function(){
var ld=this.getParameter('sysparm_lsd');
var ed=this.getParameter('sysparm_led');
var id=gs.dateDiff(ld,ed,false);
return id;
},
type: 'calculatedates'
});
Client Script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var lsd=g_form.getValue('u_leave_start_date');
var led=g_form.getValue('u_leave_end_date');
var dt= new GlideAjax('calculatedates');
dt.addParam('sysparm_name','datediff1');
dt.addParam('sysparm_lsd',lsd);
dt.addParam('sysparm_led',led);
dt.getXML(ct);
function ct(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('u_total_days',answer);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2019 02:10 AM
I want weekdays(working days)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2019 03:23 AM
Use Glideschedule