The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

Calculate the difference between two date/time fields in a numeric field

Trevor Overstreet
Contributor
February 1, 2024

Hey Community!

I am attempting to calculate the difference between a date/time field and display how long it took in time (numeric field <- if this is the correct field type for the formula).

Example:

Field: "Incident Detect time" is 6/26/23 6:34:00 AM

Field: "Start time" is 6/26/2023 5:23 AM

Current formula in automation: 

{{issue.customfield_13159.diff(issue.customfield_13462).days}}

But when using this formula it calculated 0, when I need it to be 6:34:00 AM - 5:23 AM = 1.11.

Should .days in the formula be something else?

 

Screenshot 2024-02-01 at 6.26.34 PM.png

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

2 votes
Answer accepted
Mayuresh Kamble
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 Champions.
February 1, 2024

Hi @Trevor Overstreet ,

Create MTTD field as a text type and then use the smart value in the automation - {{issue.customfield_13159.diff(issue.customfield_13462).days}} or {{issue.customfield_13159.diff(issue.customfield_13462).prettyPrint}}

Regards,
Mayuresh

Trevor Overstreet
Contributor
February 2, 2024

Hey Mayuresh,

I recreated the field to be text and tried both formulas above with no luck. The .days still displayed 0. And .prettyPrint displayed "0 seconds". 

Any ideas on how to get the difference to 1.11?

Trevor Overstreet
Contributor
February 2, 2024

Actually the formula may be working (.prettyPrint). Continuing to test

Trevor Overstreet
Contributor
February 2, 2024

The calculation works and changed to {{issue.customfield_13159.diff(issue.customfield_13462).minutes}} to only show minutes. Thank you!

Mayuresh Kamble
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 Champions.
February 4, 2024

Hi @Trevor Overstreet ,

Glad to know that it worked!

DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events