Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,641,737
Community Members
 
Community Events
196
Community Groups

How to calculate two date fields and show the difference in days in number?

Hi, 

I have two fields Date A and Date B, I would like to subtract these fields for example {Date A} - {Date B} and return the value in days or number is it possible? in the example above I use the number value and string value and the result is not as expected. I'm using the JWT CAlculated Number.

Result: Calculated Date-Time

Data A: 08/May/20
Data B: 09/May/20
Data Total: 31/12/69 21:00

Result: Calculated Number Field

Data A: 08/May/20
Data B: 30/May/20

           Data Total N : 0

3 answers

1 accepted

6 votes
Answer accepted
Thorsten Letschert _Decadis AG_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
May 10, 2020

Hi @Fernando Passos ,

given your two fields and assuming Date B is the larger one, the expression should look like:

round({bbbbb} - {aaaaa}) / {DAY}

Please replace aaaaa and bbbbb with the field codes for Date A and Date B.

Since you might want to ensure that the calculation will only be executed if both fields are set, I'd recommend the following expression:

{aaaaa} != null AND {bbbbb} != null ? round({bbbbb} - {aaaaa}) / {DAY} : null

Cheers
Thorsten

Hi @Thorsten Letschert _Decadis AG_ ,

Perfect! I had the result I expected, thank you very much.

I used this one. round ({Data B} - {Data A}) / {DAY}

Like Pitty likes this

Thank you very much!

6 votes
John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 08, 2020

Hi Fernando,

I use Automation For Jira to do that. I created a number field then populate it with this:

{{issue.customfield_17152.diff(issue.customfield_16921).days}}

Hi John,

Thanks for the help, but we don't have automation for jira in the company, we have script runner, behavior and the JIRA workflow Toolbox. Can we achieve this result with the add-ons we have?

Like Hugo Oliveira likes this
John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 08, 2020

I don't use any of those. You would need to contact their support directly. Sorry. 

@John Funk It worked perfectly, thank you very much!!

Like # people like this
1 vote
Sebastian Krzewiński
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 08, 2020

Hi @Fernando Passos 

 

Please check Adaptavist Script runner library - https://library.adaptavist.com/

 

There you can find helpful scripts ready to use, e.g. - https://library.adaptavist.com/entity/calculate-the-difference-between-two-dates

 

Regards,

Sebastian

Hi @Sebastian Krzewiński

Thanks, I'll check and return. 

Like Sebastian Krzewiński likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.7.0
TAGS
AUG Leaders

Atlassian Community Events