How to exclude weekends while calculating date in custom form in flow ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago - last edited 2 hours ago
How to exclude weekends while calculating date in custom form in flow ?
After Lookup records on Custom Form and For each condition
For eg 1.DueDate + 5 days Logic as below
Duedate relative before 4 days ago and Due date relative after 6days ago
Similarly
1.DueDate + 3 days Logic as below
Duedate relative before 2 days ago and Due date relative after 4 days ago
Provide Weekend exclusion logic based on above condition in Flow in ServiceNow.
After which Notification to be triggered.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
are you trying to get difference between 2 dates or 2 date/time in flow?
if yes then use flow variable and use "Set Flow Variables" flow logic and refer below scripts and get that
var startDateGdt = new GlideDateTime();
startDateGdt.setValue('startDateHere');
var endDateGdt = new GlideDateTime(current.end_date_here);
var days = getDateDiffExcWeekends(startDateGdt,endDateGdt);
function getDateDiffExcWeekends(start,end){
var days = 0;
while (start < end) {
start.addDaysUTC(1);
if (start.getDayOfWeekUTC() != 6 && start.getDayOfWeekUTC() != 7){
days++ ;
}
}
return days+1;
}
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader