- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-22-2022 07:42 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-24-2022 10:30 PM
Hi,
907200 is seconds and it comes to 10.5 days.
Please verify it from your side what does that schedule contains, holidays etc
8 to 5 means 9 hours -> and it doesn't mean 1 day
1 day -> 24 hours
Also check the docs
Using DurationCalculator to calculate a due date
DurationCalculator calcScheduleDuration Mystery
If you take the start date as 15th June, 2022 and End Date as 23rd July, 2022
1) it comes to 28 working days excluding weekends; I am not sure if there are holidays in your schedule, I checked 8 -5 excluding holidays in my instance and there is no US holiday in it
2) so it comes to 28(days)*9(hours per day) = 252 hours
3) and 9hrs = 1 business day
4) so it comes to 252/9 = 10.5 business days
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-22-2022 07:51 AM
Hi,
if you just want to exclude weekends then use this
var start = new GlideDateTime('<start>');
var end = new GlideDateTime('<end>');
var days = getDateDiffExcWeekends(start, end);
gs.info(days);
function getDateDiffExcWeekends(start , end){
var days = 0;
while (start < end) {
start.addDaysUTC(1);
if (start.getDayOfWeekUTC() != 6 && start.getDayOfWeekUTC() != 7){
days++ ;
}
}
return days;
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-23-2022 01:14 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-24-2022 05:07 AM
Hi Ankur,
Thanks for the script, it worked exactly well and gave me the number of days difference excluding saturday and sunday.
But I also want to exclude holidays as well, where in having a schedule.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-24-2022 10:22 PM