- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2023 03:12 AM
Hi All,
Please help me on the below requirement.
I have created NBD and 2BD relative duration.
NBD-if the incident is raised at any time it should complete next business day at 6.30
2BD-if the incident is raised at any time it should complete 2 business day at 6.30
For the above requirement i have created by using script.
Now how can i add to exclude 2nd&4th Saturday, Sunday and public holiday. please help me on this
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2023 04:15 AM
Hi Nikitha,
To achieve this, you need to use a schedule that defines the working days and hours, as well as the holidays, that you want to exclude from the relative duration. A schedule is a record that specifies the time periods when a process or task can run or is active. You can create a custom schedule or use an existing one that meets your requirements.
Once you have a schedule, you can use the DurationCalculator script include to calculate the due date using the schedule. The DurationCalculator script include provides methods to calculate a due date based on a simple duration or a relative duration. You can use the setSchedule() method to specify the schedule and the timezone that you want to use for the calculation. Then, you can use the calcRelativeDuration() method to calculate the due date based on a relative duration record.
Here is an example of how you can modify your script to use a schedule and a relative duration:
// Create a DurationCalculator object
var dc = new DurationCalculator();
// Set the start date and time of the incident
dc.setStartDateTime(“2021-10-01 10:00:00”);
// Set the schedule and timezone that you want to use
// Replace the sys_id with your custom schedule sys_id
dc.setSchedule(“08fcd0830a0a0b2600079f56b1adb9a2”, “Asia/Kolkata”);
// Calculate the due date based on a relative duration record
// Replace the sys_id with your NBD or 2BD relative duration sys_id
dc.calcRelativeDuration(“3bfa9bd10a0a0b5200c18037fbaa9a2c”);
// Print the due date
gs.print(dc.getEndDateTime());
Hope this helps.
Kind Regards,
Swarnadeep Nandy

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2023 04:15 AM
Hi Nikitha,
To achieve this, you need to use a schedule that defines the working days and hours, as well as the holidays, that you want to exclude from the relative duration. A schedule is a record that specifies the time periods when a process or task can run or is active. You can create a custom schedule or use an existing one that meets your requirements.
Once you have a schedule, you can use the DurationCalculator script include to calculate the due date using the schedule. The DurationCalculator script include provides methods to calculate a due date based on a simple duration or a relative duration. You can use the setSchedule() method to specify the schedule and the timezone that you want to use for the calculation. Then, you can use the calcRelativeDuration() method to calculate the due date based on a relative duration record.
Here is an example of how you can modify your script to use a schedule and a relative duration:
// Create a DurationCalculator object
var dc = new DurationCalculator();
// Set the start date and time of the incident
dc.setStartDateTime(“2021-10-01 10:00:00”);
// Set the schedule and timezone that you want to use
// Replace the sys_id with your custom schedule sys_id
dc.setSchedule(“08fcd0830a0a0b2600079f56b1adb9a2”, “Asia/Kolkata”);
// Calculate the due date based on a relative duration record
// Replace the sys_id with your NBD or 2BD relative duration sys_id
dc.calcRelativeDuration(“3bfa9bd10a0a0b5200c18037fbaa9a2c”);
// Print the due date
gs.print(dc.getEndDateTime());
Hope this helps.
Kind Regards,
Swarnadeep Nandy