Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Getting result in negative.

shivani.shirguppi December 17, 2024

 

 

I want to calculate how much time the ticket took from creation to resolve using automation. I have used 

{{issue.resolutiondate.diff(issue.created).hours}} Hours 

smart value but after running the automation I am getting the negative result (ex -97 hours) even if the resolved date is after created date

1 answer

1 accepted

5 votes
Answer accepted
Tuncay Senturk _Snapbytes_
Community Champion
December 17, 2024

Hi @shivani.shirguppi 

What I'd do first is to ensure both {{issue.created}} and {{issue.resolutiondate}} have valid, properly formatted values. You can test this by logging these dates

 

Created: {{issue.created}}
Resolved: {{issue.resolutiondate}}

If the difference still shows as negative, it might be because the smart value's .diff() method interprets the order incorrectly. You can use the .abs() function to handle this or the other way around

 

{{issue.resolutiondate.diff(issue.created).hours.abs}} Hours
or 
{{issue.created.diff(issue.resolutiondate).hours.abs}} Hours
shivani.shirguppi December 17, 2024

Thank you so much @Tuncay Senturk _Snapbytes_ 

Tuncay Senturk _Snapbytes_
Community Champion
December 17, 2024

No problem! I'm glad it helped.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events