Duration field to display only number of days

Sakshi Lambat
Tera Contributor

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.

5 REPLIES 5

udaysingh16
Tera Contributor

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.

udaysingh16
Tera Contributor

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()

siraj5
Tera Contributor

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!

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Sakshi Lambat 

 

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]

****************************************************************************************************************