- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2022 07:12 AM
Hi,
I am having string type of fields which is calculating the difference between 2 date fields and storing into a string type of field.. So, the value appears in the format of days, hours, minutes, seconds.
(ex: 2 days, 10 hour, 45 minutes, 20 seconds)
But for reporting purpose it is not feasible to calculate .Hence , we want to convert into numeric value(minutes/seconds), etc to calculate properly.
(Ex: 6000) .
So, in excel once report extracted will not face any issue.
Please guide me here, how to get that
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2022 12:35 AM
Hi,
try this
(function executeRule(current, previous /*null when async*/ ) {
//To display duration between RITM created time and RITM closed time
var start = new GlideDateTime(current.opened_at); //opened time
var end = new GlideDateTime(current.closed_at); //closed time
var dc = new DurationCalculator();
var sch = gs.getProperty('BusinessHoursSchedule');
dc.setSchedule(sch);
var time = dc.calcScheduleDuration(start, end);
var durationMS = time * 1000;
current.u_lifecycle_duration.setDateNumericValue(durationMS);
})(current, previous);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2022 12:35 AM
Hi,
try this
(function executeRule(current, previous /*null when async*/ ) {
//To display duration between RITM created time and RITM closed time
var start = new GlideDateTime(current.opened_at); //opened time
var end = new GlideDateTime(current.closed_at); //closed time
var dc = new DurationCalculator();
var sch = gs.getProperty('BusinessHoursSchedule');
dc.setSchedule(sch);
var time = dc.calcScheduleDuration(start, end);
var durationMS = time * 1000;
current.u_lifecycle_duration.setDateNumericValue(durationMS);
})(current, previous);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2022 01:23 AM
Hi