Forums

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

Impossible to use date functions with created variables in Automation

Cédric Cox
Contributor
January 21, 2021

Hi everybody,

In a JIRA Automation rule, I create intermediate variables to work and manipulate dates comming from custom fields. However, I find it impossible to use the date functions (as .diff for example) with these variables.

For example, something like {{mydate2.diff(mydate1).days}} returns a null value. I checked the value of mydate1 and mydate2 with a log just above, to be sure these variables are well filled.

I also tried to recast these variables as dates to be sure to work on dates, as mentionned in the documentation: mydate1 = {{mydate1.toDate}} and mydate2 = {{mydate2.toDate}}, but this changes nothing.

Is there any known issue with this? Any tips?

Thanks

Cédric

2 answers

0 votes
Bill Sheboy
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 Leaders.
January 21, 2021

Hi @Cédric Cox 

If I am understanding your question, you are using created variables within the rule and the date functions are not working.  Is that correct?

If so, I suspect that the created variables are strings, and so you may need to convert them to a date first, such as with {{myVariable.toDate}}

You may check progress when building rule formulas by using the action Log to write to the audit log and see the results.

Best regards,

Bill

0 votes
Manon Soubies-Camy
Community Champion
January 21, 2021

Hi @Cédric Cox,

Can you try to use the diff with .seconds instead of .days?

{{mydate2.diff(mydate1).seconds}}

I've had issues with durations that were < 1 day, resulting in the diff value being null. For example:

  • if mydate2.diff(mydate1) = 4 hours
  • then {{mydate2.diff(mydate1).days}} = 0

Hope this helps,

- Manon

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events