- 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 07:59 AM
I have not used time zone, just sys_id of the schedule
var start = new GlideDateTime('2019-04-01');
var end = new GlideDateTime('2019-04-30');
var dc = new DurationCalculator();
dc.setSchedule('08fcd0830a0a0b2600079f56b1adb9ae'); // Schedule sys_id
var dur = dc.calcScheduleDuration(start, end);
var business_days = dur/(60*60*9); // Update the total hours of a day based on shedule
gs.info(business_days);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2019 08:30 AM
all months are showing 1 day less
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2019 08:31 AM
For May2019 it should be 23 , where as its giving 22

- 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 08:42 AM
But for march I'm getting the correct value