String to date casting issues.

Peter Pshenichny December 23, 2021

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

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.
December 23, 2021

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
AUG Leaders

Atlassian Community Events