Smart values date difference using a hard coded value

Manohar Kurapati March 4, 2020

Hi 

Using Jira cloud automation, I am trying to find out the days difference between a value in jira field to the hardcoded date value divided by 14.

Documentation only provides use cases that find the difference between now and date value in Jira field. 

{{#=}}{{now.diff(issue.Expected Date).days}} / 14 {{/}}

I am trying to find something like below

{{#=}}{{(08/01/2020).diff(issue.Expected Date).days}} / 14 {{/}}

Please can you help how to get the above working?

1 answer

1 accepted

0 votes
Answer accepted
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 13, 2020

Hello @Manohar Kurapati ,

 

If I understand correctly, you are using automation for Jira Sofware Cloud and you are referring to the below documentation pages:

 

If that's the case, then a quick way to proceed would be to:

  1. Add a custom field to store the hard-coded date, let's call it HardCodedDate
  2. Fill the custom field with the desired date (e.g. 08/01/2020)
  3. Replace 'now' with the HardCodedDate custom field in the formula you already know:
    {{#=}}{{issue.HardCodedDate.diff(issue.Expected Date).days}} / 14 {{/}}

 

 

I hope this helps.

 

Cheers,
Dario

Dionei Piazza September 3, 2020

@Dario B , I have a point here.

The example of @Manohar Kurapati is looking for ".days". If the difference between the two dates does not complete a day, is the result 0 (zero) or something like 0.5 days?

Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 29, 2021

Hello @Dionei Piazza ,

Sorry for late reply, I am afraid I have missed your comment. However, even if I have never encountered this scenario myself the assumption is that it returns 0.

Also, looking at the example in the documentation (quoted below) I assume that using prettyPrint the function will return the amount of hours as well:

 displays the difference in words, e.g.: 2 days 3 hours.

 

Please let me know if this is something that you still need to know so that, in case it is, I can ask the Automation team for clarifications.

 

Cheers,
Dario

Like Dionei Piazza likes this
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 3, 2021

@Dionei Piazza ,

I have asked the automation team and I have been told that it actually depends on the kind of fields:

yes it should display in hours. If both fields are date time fields. If they are just date fields (no time information) then it will likely be 0.

 

I hope this helps

Like Dionei Piazza likes this
Dionei Piazza February 3, 2021

Hi @Dario B !

Thank you very much!

Cheers,
Dionei!

Like Dario B likes this
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 4, 2021

You are very welcome @Dionei Piazza ! :) 

Also, as an advice for the future, you have bigger chances to get a quick reply if you create a new question, instead of adding the question to a thread that is older than couple of months (unless it is an active thread).

 

Cheers,
Dario

Suggest an answer

Log in or Sign up to answer