How to add 5 days to a date excluding weekends
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2022 05:15 AM
Hi,
I have a date, I need to add 5 days to it which should exclude weekends. I am using this code on a scheduled job code block.
var triggerFirstNotification = "24/05/2022";
var addDaysFive = new GlideDateTime(triggerFirstNotification);
addDaysFive.addDaysUTC(5);
var days = 0;
if (addDaysFive.getDayOfWeekUTC() != 6 && addDaysFive.getDayOfWeekUTC() != 7) {
days++;
}
I should get the output as 30/05/2022. Which should include the current date as well in its count.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2022 05:24 AM
Hi Hari,
Refer the similar community article with an accepted response - https://community.servicenow.com/community?id=community_question&sys_id=40ef47a5dbdcdbc01dcaf3231f961947
Regards,
Deepankar Mathur

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2022 05:37 AM
Hi Hari,
Here is a correct answer mentioned just replace 3 days with 5 days:
Mark my answer correct & Helpful, if Applicable.
Thanks,
Sandeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2022 10:40 AM
The answer in the post doesn't meet the requirement that i am look for. I have a date and i need to add 5 days to it which should exclude weekends.