How to Calculate Total Business Duration since Created on date to now date
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2024 11:14 AM
Hi,
I need to calculate Business duration from Idea being Created on to till present day.
Below is the script i used so far:
var start = new GlideDateTime(gr.sys_created_on);
var end = new GlideDateTime(gs.now());
var dc = new DurationCalculator();
dc.setSchedule('sys_id of schedule');
var dur = dc.calcScheduleDuration(start,end);
var dur1 = new GlideDuration(dur);
gr.u_total_duration = dur1.getDurationValue();
here i am getting only minutes
1 REPLY 1

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2024 11:24 AM
Hi Supriya,
You may try with below code :
var sys_created_on = new GlideDateTime('2024-09-10 00:00:00'); // Replace it with gr.sys_created_on
var current_system_date = new GlideDate();
var schedule = new GlideSchedule('08fcd0830a0a0b2600079f56b1adb9ae', '8-5 weekdays'); // Replace it with the sys_id of the schedule (Try with GlideRecord and no hardcoding)
var duration = schedule.duration(sys_created_on, current_system_date);
gs.info(duration.getDisplayValue());