Duration field to display only number of days
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2024 10:17 PM
Hi All,
I want to create a report for the Incident table where I want the field Same Day Closure (It must calculate the difference between the closed time and the opened time) it must return the value in the form of Days only. Now the output is coming in the form of DD-HH-MM. Please help me solve this issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2024 12:16 AM
Hi @Sakshi Lambat ,
var start = new GlideDateTime(current.opened_at);
var end = new GlideDateTime(current.u_resolved_at);
var xx = GlideDateTime.subtract(start, end);
gs.log(xx.getDisplayValue(), "JC");
// Optuput : 'x' days 'y' minutes
Please try this and mark this helpful if this works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2024 12:17 AM
If you are using 'GlideDuration' than use the following
var duration = new GlideDuration('23:24:41');
duration.getDisplayValue(); //this will give you the required format
You can convert it to Days Hours Minutes by using duration.getDisplayValue()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2024 12:45 AM
Hi
Please go through this Link, it may be helpful for your problem.
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0563750
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2024 03:00 AM
I guess it has been answered by Anurag and others in another post.
Add an attribute max_units = Days.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************