Forums

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

Date Calculations - Syntax

Jonathan Cunliffe
Contributor
July 5, 2023

Hi everyone,

Hopefully an easy one here.  I want be able to calculate, in Jira Automation, the duration (in business days) between two dates.

I've used:

Duration would = {{issue.Start date.diff(issue.duedate.plusDays(1)).businessDays}}d

This works great if that start and due dates are more than a day apart, but not if they are the same date, it returns null.

I think I may have the wrong syntax/position for the .plusDays(1).

Any help greatly appreciated.

Cheers,
JonC

1 answer

0 votes
Evgenii
Community Champion
July 5, 2023

Hi, @Jonathan Cunliffe 

After some examination of documentation, looks like you need to experiment with if conditions, they can help in your case.

https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/

Take a look at isEquals() method.

Jonathan Cunliffe
Contributor
July 5, 2023

Hi @Evgenii 

Thanks for the speedy response.  I must be missing something here as I'm not getting anything back from the formula.

I've enter it as:

t1.jpg

But get back:

t2.jpg

Am I missing something here?

Thanks again.

Like John Funk likes this
Evgenii
Community Champion
July 5, 2023

Try this. Checked it, it's working. First variant was completely wrong.

{{#if (equals(issue.Start date.jiraDate, issue.duedate.jiraDate))}}
0d
{{/}}
{{#if (not(equals(issue.Start date.jiraDate, issue.duedate.jiraDate)))}}
{{issue.Start date.diff(issue.duedate.plusDays(1)).businessDays}}d
{{/}}

Like John Funk likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events