Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
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

String to date casting issues.

Hi,

I'm working on Automation rule, and I want to make sure a task belongs to the currently running sprint.

I have a {{issue.sprint.startDate}} and {{issue.sprint.endDate}}, and I want to compare it with {{now}}

Now the problem is that {{now.isAfter(issue.sprint.startDate)}} always return nothing (null I guess).

The only reason I can think of - `startDate` is not a date type, so I was trying to cast it to date with no success.

Please suggest how to compare `startDate` and `now`?

Here is the tests I done:

With no Formatting:
start Date: {{issue.sprint.startDate}}
now: {{now}}
now is before now: {{now.isBefore(now)}}
now is before start Date : {{now.isBefore(issue.sprint.startDate)}}

With .toDate
start Date: {{issue.sprint.startDate.toDate}}
now: {{now.toDate}}
now is before start Date : {{now.isBefore(issue.sprint.startDate.toDate)}}

With .jiraDate
start Date: {{issue.sprint.startDate.jiraDate}}
now: {{now.jiraDate}}
now is before start Date : {{now.isBefore(issue.sprint.startDate.jiraDate)}}

With .jiraDate.toDate("yyyy-MM-dd")
start Date: {{issue.sprint.jiraDate.toDate("yyyy-MM-dd")}}
now: {{now.jiraDate.toDate("yyyy-MM-dd")}}
now is before start Date : {{now.isBefore(issue.sprint.jiraDate.toDate("yyyy-MM-dd"))}}

------

With no Formatting:
start Date: Thu Dec 16 09:59:02 UTC 2021
now: 2021-12-23T16:29:20.0+0000
now is before now: false
now is before start Date :

With .toDate
start Date:
now:
now is before start Date :

With .jiraDate
start Date: 2021-12-16
now: 2021-12-23
now is before start Date :

With .jiraDate.toDate("yyyy-MM-dd")
start Date:
now: 2021-12-23T00:00:00.0+0000
now is before start Date :

 

1 answer

Hi @Peter Pshenichny -- Welcome to the Atlassian Community!

Have you tried checking the attribute state for the sprints to find the active one using smart value, list filtering?  For example, please try writing this to the log:

Active sprint: {{#issue.sprint}}{{#if(equals(state,"active"))}}{{name}}{{/}}{{/}}

Here is more information on the conditional processing functions: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-conditional-logic/

And regarding what you observed with dates, the sprint smart value is a list so you may need to access an individual item, such as {{issue.sprint.first.startDate}} when there are multiple values in the field.

Kind regards,
Bill

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
Community showcase
Published in Jira Software

👋 Looking for 15-20 volunteers to test Atlassian training content

Hi everyone! Are you interested in beta testing Atlassian University’s newest (unreleased!) training course? We’re looking for 15-20 volunteers to test our newest training course, Basic reporting...

558 views 20 25
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