- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2016 05:12 PM
I need to calculate the duration between two dates, given a schedule, in a scoped app and I'm really having trouble.
this is the code I'm using (sorry, first post and I forget how to put the code into the formatter);
There is a record with an 'employee' field referencing sys_user, a start_date and an end_date field.
***************
var emplSched = current.employee.schedule;
var startDate = new GlideDateTime(current.start_date);
var endDate = new GlideDateTime(current.end_date);
var schedule = new GlideSchedule(emplSched);
var dur = schedule.duration(startDate,endDate);
var days = dur.getNumericValue() /1000 /60 /60 /25;
***************
if I put 2 weeks (Monday to a week Friday), days is returning 3
I basically followed the suggestions in this post: Use DurationCalculator in scoped application?
I've tried adding the timezone but no luck...
ANY help would be appreciated! Thanks in advance!!
FYI - I've used durationcalculator a hundred times and I WISH I could use it in a scoped app!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2016 06:34 PM
I believe that's the correct answer. In a two-week period, assuming a 40-hour week, there are 80 hours. This in duration would be 80 / 24 ~ 3.3 days.
Hope this helps.
Please feel free to connect, follow, mark helpful / answer, like, endorse.
John Chun, PhD PMP ![]() | ![]() |
Winner of November 2016 Members' Choice Award
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2016 06:34 PM
I believe that's the correct answer. In a two-week period, assuming a 40-hour week, there are 80 hours. This in duration would be 80 / 24 ~ 3.3 days.
Hope this helps.
Please feel free to connect, follow, mark helpful / answer, like, endorse.
John Chun, PhD PMP ![]() | ![]() |
Winner of November 2016 Members' Choice Award
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2016 07:16 PM
Oh man... yes of course!... not 24 hours a day... 8! That works better.
Yikes, thanks John... too long at it and not paying attention!
Thank you!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2016 07:23 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2016 07:26 PM