Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
Level
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Automation for Jira - Comparing two date fields

I'm trying to get the number of days between the issue created date and a custom date field called closed date (also tried the system issue.resolutiondate but that didn't work either). No matter what the dates are set to in the issue, the automation rule will only return 1 in the target field. All of the examples in the documentation for date functions list comparing to  (now), but I want to compare it to another date field. How do? 

1 answer

1 accepted

2 votes
Answer accepted

Hi Jamie

To get diff between two dates fields I used something like this:

{{issue.customfield_10015.diff(issue.customfield_10016).minutes}}

In my case I want to had diff in minutes but you can easily switch this to days.

Helpful docs:

- date attributes - https://docs.automationforjira.com/working-with-issue-data/date-functions.html#attributes-of-a-date

- calculate the difference between two dates -  https://docs.automationforjira.com/working-with-issue-data/date-functions.html#calculating-the-difference-between-two-dates

Let me know if this help you :)

 

Regards,

Sebastian

Thank you Sebastian! My syntax was off, that was the problem (as usual). 

@Sebastian Krzewiński Where do you add this script please ? 

Hi @Assia Touati You can add it wherever you want (comment body, field value). In my case I added it as a value of text field.

You must remember that field type must me correct with result type (e.g. if you want put something in number field diff result should be a number).

Like Assia Touati likes this

so the difference between two timedate in hours should be put in a number field ? am i right ? @Sebastian Krzewiński 

It can be put in text field. It depends what you need do next with it.

Hello @Sebastian Krzewiński ,

 

Thanks in advance. 

I have one scenario where I have start date and end date and want to populate the difference in field duration which is number field. 

Can you please help me in configuring this.
I tried populating result in description field but not getting anything there. 

 

Regards,

Abhi

Hi @abhishek_singh 

Please check - https://support.atlassian.com/jira-software-cloud/docs/smart-values-date-and-time-functions/

 

In your case I will probably use {{[date1].diff([date2]).[unit]}} smart value.

You should use this value in proper field in action edit issue.

 

Regards,

Sebastian

Hello @Sebastian Krzewiński ,

 

Thanks for your reply.

I got the solution.

 

Regards,

Abhi

Like Sebastian Krzewiński likes this

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

New Cloud Apps Roundup - April 2021

Atlassian's marketplace partners have had a very productive start to 2021! Since our last roundup, our developer community has added over 160 new cloud apps to the Atlassian Marketplace to help you...

283 views 3 20
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you