GlideSchedule not working in scoped application

Vishal V R
Kilo Contributor

Hi All,

 

Below script is not working while trying to run in fix script to calculate time differnce. 

Can anyone help pls. 

 

var startDate = new GlideDateTime('2019-06-10 02:00:00');
var endDate = new GlideDateTime('2019-06-23 04:00:00');
var schedule = new GlideSchedule();
 
schedule.load('ca0f80c7db467300547bf456bf961954'); -> runs all day and  on weekdays
var duration = schedule.duration(startDate, endDate);
gs.info('log1'+duration.getDurationValue());  -- > returning a value of  1 06:00:00
var durations = duration.getNumericValue();
gs.info('log2'+durations/(3600000*24)); --> returning value of 1.25

4 REPLIES 4

Prateek kumar
Mega Sage

Try this?

 

var startDate = new GlideDateTime('2019-06-10 02:00:00');
var endDate = new GlideDateTime('2019-06-23 04:00:00');
var schedule = new GlideSchedule();
 
schedule.load('ca0f80c7db467300547bf456bf961954'); -> runs all day and  on weekdays
var duration = schedule.duration(startDate, endDate);
gs.info('log1'+duration.getDurationValue());  -- > returning a value of  1 06:00:00
var durations = duration.getDurationValue();
gs.info('log2'+durations/(3600000*24)); --> returning value of 1.25


Please mark my response as correct and helpful if it helped solved your question.
-Thanks

Getting NaN.

what is the result you are expecting?

 


Please mark my response as correct and helpful if it helped solved your question.
-Thanks

SanjivMeher
Kilo Patron
Kilo Patron

Below link should help

 

https://community.servicenow.com/community?id=community_question&sys_id=8711d7e9dbdcdbc01dcaf3231f96...


Please mark this response as correct or helpful if it assisted you with your question.