Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

GlideSchedule gives incorrect values

vijayalalitha
Tera Contributor

My requirement is to add 6 working days(excluding Saturday and Sunday) to a given date . I have created "24*5" schedule and the below script for achieving this but the output gives me incorrect date as weekend as shown below.

 

var days=6;
var startDate = new GlideDateTime('2023-12-29 00:00:00'); //Given date
var dur = new GlideDuration(60 * 60 * 24 * 1000 * days);
var schedule = new GlideSchedule('9b4bd703871c4e50e0ac65370cbb3569'); //Sys_id of 24*5 scheduled
var end = schedule.add(startDate, dur);
gs.info(end)

 

OUTPUT:

Script: 2024-01-06 00:00:00

 

0 REPLIES 0