Calculate Ticket Closure time on resolution

Hello Guys,

I’m trying to Calculate Ticket Closure time on resolution and for this i am thinking of using a scrip to be triggered on resolution and which would access the time created and resolved subtract them and update a custom field.

Anyone of you have done this before?

How can i access the times? and also is it possible to make any airthmatic operations on the time?

Response would be sincerly appreciated since this needs to implemented ASAP.

Thanks,
Nishanth Shenoy

You can definitely do this with a scrip and set a custom field value to store it, It may be worth searching around here for a similar question I feel its been asked before.

How can i access the times? and also is it possible to make any airthmatic operations on the time?

RT has a great date module that can calculate the differences between two date objects. So you could set one to “now”: $resolvedDate->SetToNow and then get the created date object from the ticket $self->TicketObj->CreatedObj.

Last you can use the Diff date method to get the time between the two date objects and set some custom field to that diff value.

@knation, I’m doing something like this.

my $cf1 = $self->TicketObj->ResolvedObj->Unix;
my $cf2 = $self->TicketObj->CreatedObj->Unix;
my $cf3 = $cf1 - $cf2;

Now i want to represent the unix time in dd:hh:ss format. can you please tell me how do i use DurationAsString on this value to get what i want?

You can use the Set method for a RT::Date object:
https://docs.bestpractical.com/rt/4.4.4/RT/Date.html#Set

I was not able to perform this using the Date class.

However i used a simple math logic to achieve what i needed.

Thanks @knation for your help,

If you need to track elapsed business hours from create to close time, things get more complicated. I’ve written an extension which does that: https://github.com/catalyst-cloud/RT-Extension-ElapsedBusinessHours