need help to create report which shows number of days between when Ticket was Opened and Closed for a particular month

karan15
Tera Contributor

need help to create report which shows number of days between when Ticket was Opened and Closed for a particular month 

 

For e.g I can see using attached query that there were 1500 tickets created and closed in Jan 2022 however can I create a report some how to show for how long each ticket was opened for ?

E.g - Ticket created on 2 Jan 2022 , closed on 4th Jan 2022 >> number of days ticket was opened for is 2 days 

 

Thanks 

6 REPLIES 6

SAI VENKATESH
Tera Sage
Tera Sage

Hi @karan 

 

with respect to this requirement you need to create a custom field and you can store the difference in that custom field and show that field in report based on your report type.

 

and for getting difference between 2 dates you can refer the below code as sample.

 

var gdt1 = new GlideDateTime("2011-08-28 09:00:00");


var gdt2 = new GlideDateTime("2011-08-31 08:00:00");


var dur = new GlideDuration();



var dur = GlideDateTime.subtract(gdt1, gdt2); //the difference between gdt1 and gdt2


gs.print(dur.getDisplayValue());

 

 

Thanks and Regards

Sure Sai Venkatesh

Maik Skoddow
Tera Patron
Tera Patron

Hi @karan 

you don't need a custom. You can leverage so-called function fields for reporting where the calculation is done really easily.

See https://docs.servicenow.com/bundle/rome-now-intelligence/page/use/reporting/task/create-function-fie...

And there is a Performance Analytics episode which handles function fields in reports: https://www.youtube.com/watch?v=jHc5YLXfU_o

Kind regards
Maik

thanks ill try that 

Hi @karan 

In case you think I was able to answer your question, I would be happy if you mark the appropriate response as "correct" so that the question will appear as resolved for other users who may have a similar question in the future.

If not, please tell me what you are still missing.

Many thanks & kind regards
Maik