Automation for Jira: syntax for "Is today between two dates"?

Fred Lunau February 26, 2020

I'm trying to write a rule that triggers when an Issue transitions to a certain status, with a condition that includes if-else blocks.  I'm stuck on the correct magic for the date logic in the condition, which looks like:

  • if today is between two dates --> set a field value to XX
  • if today is between two other dates  --> set a field value to YY
  • etc...

So if {{ now.isAfter("2019-12-01") }} is true, and if {{ now.isBefore("2020-02-28") }} then set field to XXX

When the rule triggers, the {{ now.isAfter("2019-12-01") }}, it tells me that the Issue did not match the condition.  

Does anyone know how to get that expression can resolve to true?  Tried using .toDate, .jiraDate, and a bunch of other things, to no avail.

thanks in advance!

now1.jpg

1 answer

1 vote
Ármin Scipiades May 13, 2020

Hi. I was trying to do the exact same thing. The smart value expression you posted (`now.isAfter("2020-05-10")`) actually gives a blank result, which is weird. Using toDate and the rest gave me errors.

There's an unwieldy expression that does work:

{{ now.isAfter(now.withYear(2020).withMonth(5).withDayOfMonth(10)) }}

This gives the desired result, but I think it's a bit of a hack, I'd think there's a less ugly way to do this.

Oh and: I posted this as a question on StackOverflow: https://stackoverflow.com/q/61782620/477453

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events