GlideSchedule not working in scoped application
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2019 01:11 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2019 02:47 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2019 02:53 PM
Getting NaN.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2019 03:00 PM
what is the result you are expecting?
Please mark my response as correct and helpful if it helped solved your question.
-Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2019 04:48 PM
Below link should help
Please mark this response as correct or helpful if it assisted you with your question.