Get next business day (date/time - based on schedule)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2016 01:56 AM
Hi all,
do you have any script to accomplish this?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2016 02:18 AM
HI william
This script may help you
// Add your code here |
var open = new GlideDateTime("2016-10-08 05:00:00");
gs.log(open+'1');
//var nowGdt = new GlideDateTime(open);
var myScheduleName = '8-5 weekdays';
var dueDays = 1;
var dueWorkingHours = 9;
var dueSeconds = dueDays*dueWorkingHours*60*60;
var leadTime = new GlideDuration(dueSeconds*1000);
var dueDateGdt;
var schedRec = new GlideRecord('cmn_schedule');
if (schedRec.get('name', myScheduleName)) {
var sched = new GlideSchedule(schedRec.sys_id);
dueDateGdt = sched.add(open, leadTime, '');
}
gs.log("The next business day day is"+dueDateGdt);
//current.due_date = dueDateGdt; | |
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2016 02:27 AM
gs.daysAgo(-1) // it will give next day and time format in GMT.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2016 02:27 AM
var startDate = new GlideDateTime('2014-01-02'); //your start date goes here
var days = 1;
var dur = new GlideDuration(60 * 60 * 24 * 1000 * days);
var schedule = new GlideSchedule('090eecae0a0a0b260077e1dfa71da828'); //pass the sys_id of your schedule
var end = schedule.add(startDate, dur);
gs.log(end);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2016 04:04 AM
/* Load the schedule */
var schedule_sys_id = '08fcd0830a0a0b2600079f56b1adb9ae'; // OOB 8 - 5 weekday sys_id
var sch = new GlideSchedule(schedule_sys_id);
/* Calculate the time (in ms) to next schedule. It'll be close to '0' if you're currently in the schedule */
var now = new GlideDateTime();
var milliseconds = sch.whenNext(now); // Determine how much time (in milliseconds) until we are 'in' the schedule. Return -1 if never.
gs.log(milliseconds + ' milliseconds(s)');