Custom date field duration calculation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2025 03:02 AM
I have 3 custom date time fields on incident table.
field 1- Actual Resolve Time
Field 2- Incident management Engagement Time
field 3- IM Engagement Duration
I want to calculate the difference between Actual incident resolved time and incident management engagement time and map the duration in IM Engagement duration.
IM Engagement Duration = time between the Incident Engagement Time and the Actual Resolve Time
Any suggestion/script would be highly appreciated.
Regards,
Chetan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2025 03:22 AM
you can use this sample script and add in any of your server side code
var plannedDatetime = new GlideDateTime(current.getValue('start_date'));
var actualDatetime = new GlideDateTime(current.getValue('work_start'));
var dur = new GlideDuration();
dur = GlideDateTime.subtract(plannedDatetime, actualDatetime); //the difference between
current.durationField = dur;
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2025 06:44 AM
HI Ankur,
I tried this script but it's not working.