Forums

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

Jira Automations - display difference between dates in hours and minutes

Małgorzata Adamska-Piotrowska July 28, 2023

Hi
I have an automation that displays difference between two dates put in custom fields in Hours. I'm interested if it would be possible to have hours and minutes at the same time.

Smart value used is : {{[date1].diff([date2]).[unit]}}

Thanks

Gosia

3 answers

2 accepted

0 votes
Answer accepted
Kseniia Trushnikova
Community Champion
July 28, 2023

Hi @Małgorzata Adamska-Piotrowska,

Try to use just {{[date1].diff([date2])}} 

It will return difference in hours and minutes.

Małgorzata Adamska-Piotrowska July 31, 2023

Hi- it doesn't work in my case.
I use advanced settings to edit my field but without any unit the automation does not work.
{
"fields": {
"customfield_22188":
"{{issue.customfield_21712.diff(issue.customfield_21713)}}"
}
}

Kseniia Trushnikova
Community Champion
July 31, 2023

@Małgorzata Adamska-Piotrowska, what is the type of customfield_22188?

Małgorzata Adamska-Piotrowska July 31, 2023

It's a Number Field.

Kseniia Trushnikova
Community Champion
July 31, 2023

@Małgorzata Adamska-Piotrowska, got it. {{[date1].diff([date2])}} returns time difference as string like "1 hour 30 minutes". You can't add a string value to a number field, that's the error.

Please use a text field instead of customfield_22188.

Małgorzata Adamska-Piotrowska July 31, 2023

Thanks a bunch for this! It works:) 
Best

Malgorzata

0 votes
Answer accepted
Marc - Devoteam
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 28, 2023

Hi @Małgorzata Adamska-Piotrowska 

If you would use: 

{{[date1].diff([date2]).prettyPrint}}

So don't use an specified unit option, but the prettyPrint option

Małgorzata Adamska-Piotrowska July 31, 2023

Hi. Thank for the suggestion. It doesn't work though.

My final action is set in Additional Fields section and after modification it looks like this.


{
"fields": {
"customfield_22188":
"{{issue.customfield_21712.diff(issue.customfield_21713).prettyPrint}}"
}
}


Should it be done in another way?

Marc - Devoteam
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 31, 2023

Hi @Małgorzata Adamska-Piotrowska 

I see in your reply to @Kseniia Trushnikova that customfield_22188 is a number field.

Then prettyPrin can't work as you store the result in a number field, that can only contain a number.

I think you should use a text field instead

Małgorzata Adamska-Piotrowska July 31, 2023

Thanks. It worked without any unit but with prettyPrint option it doesn't.

Maybe there is also a trick somewhere else.

Like Marc - Devoteam likes this
Marc - Devoteam
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 31, 2023

Hi @Małgorzata Adamska-Piotrowska 

I don't see how, unless not using a number field as than can't contain other information than a number.

Małgorzata Adamska-Piotrowska July 31, 2023

Ok. I think I'll give it one more try.
Thanks for your help!
BR

Malgorzata

0 votes
Sharmila Hiranandani
Contributor
January 27, 2025

Hi 

I have a similar problem. I want to update one custom filed (Cust_Response Duration) of type Short text, with the difference of current time and value in a custom date field. I am using the below smart value in my automation , but every time the rule runs , the Audit log shows "No Actions Performed" , Can anyone please help as to why the custom field "Cust_Response Durantion" is not getting updated .

Smart value which I have put in the automation rule for editing the custom field Cust_Response_Duration is : 

{{now.diff(issue.Cust_Response Time)}}

Thanks

Sharmila

 

Sharmila Hiranandani
Contributor
January 27, 2025

My issue is resolved now . Thanks 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events