glide schedule duration does not give the correct result
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2022 01:56 PM
if I change the end date to "2022-01-12 10:00:00" I get the same result
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2022 03:41 PM
I would debug the times you are creating to make sure the timezones are what you think they are. My guess is that there is an extra shift and you aren't following into the window you are expecting.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2022 05:19 PM
Probably because "All day" is not checked in the schedule. When "All day" is not checked, duration calculates only on the hours of the schedule instead of the entire 24 hours per day.
Select the check box to make the schedule entry active for the entire duration.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2022 08:23 AM
thanks for your comments, but I continue with the problem, the function does not do the desired calculations when the second date has a time of 09:00:00, 10 and 13

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2022 04:41 PM
Define schedule as below:
Script:
var schedule = new GlideSchedule('de7409e09742011086d3b4b3f153af2a', 'America/Mexico_City');
var duration = schedule.duration(new GlideDateTime("2022-01-11 16:00:00"),new GlideDateTime("2022-01-12 13:00:00"));
gs.log("calcScheduleDuration with schedule: " + duration);
gs.log(duration.getDurationValue()); //this will give you answer in duration
gs.log(duration.getNumericValue()/3600000); //this will give in you in hours
Execution results:
1 End date/time is 2022-01 11:00:00
*** Script: calcScheduleDuration with schedule: 1970-01-01 19:00:00
*** Script: 19:00:00
*** Script: 19
2. End date/time is 2022-01 09:00:00
*** Script: calcScheduleDuration with schedule: 1970-01-01 17:00:00
*** Script: 17:00:00
*** Script: 17
3. End date/time is 2022-01 10:00:00
*** Script: calcScheduleDuration with schedule: 1970-01-01 18:00:00
*** Script: 18:00:00
*** Script: 18
4. End date/time is 2022-01 13:00:00
*** Script: calcScheduleDuration with schedule: 1970-01-01 21:00:00
*** Script: 21:00:00
*** Script: 21