cancel
Showing results for
Did you mean:
See all
##### Top groups
Explore all groups

## 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

Level 1: Seed

25 / 150 points

Next: Root

## Participate in fun challenges

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

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

## 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!

## 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.

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

#### 1 accepted

Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
May 10, 2020

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

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

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

Pitty likes this

Thank you very much!

John Funk
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?

Hugo Oliveira likes this
John Funk
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!!

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

Regards,

Sebastian

Thanks, I'll check and return.

Sebastian Krzewiński likes this

SERVER
8.7.0