Forums

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

Cannot calculate DateDiff using a custom date field in JPD

Adam Sigel October 7, 2024

I am trying to calculate a "Days in [Status]" field in Jira Product Discovery and can't seem to get an output for my formula.

I want to reference a custom date field that indicates the beginning of a project status and re-calculate the days in status on a daily basis with Jira Automation. I've been debugging and checking other posts in the community but have still not been able to solve this.

Here's what I have in debug now:

Now is: {{now.jiraDate}} and Discovery Kickoff is {{issue.customfield_10239.match(".*start.*([0-9]{4}-[0-9]+-[0-9]+)")}}

This works as expected and outputs:

Now is: 2024-10-07 and Discovery Kickoff is 2024-09-03

However, the next line I have for debugging fails:

Date Diff is: {{now.JiraDate.diff(issue.customfield_10239.match(".*start.*([0-9]{4}-[0-9]+-[0-9]+)")).days.abs}}

Returns this:

Date Diff is:

I've tried every formatting combination I'm familiar with and I cannot get this formula to give me a number of days since the Discovery Kickoff date. Any help is hugely appreciated!

1 answer

1 accepted

4 votes
Answer accepted
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.
October 7, 2024 edited

Hi @Adam Sigel 

When you used the match() function to extract from the JPD date field format, that results in a text value.  Please add a toDate call after that to convert before the use in diff():

Date Diff is: {{now.JiraDate.diff(issue.customfield_10239.match(".*start.*([0-9]{4}-[0-9]+-[0-9]+)").toDate).days.abs}}

https://support.atlassian.com/cloud-automation/docs/examples-of-using-smart-values-with-dates/#Converting-text-to-dates

Kind regards,
Bill

Adam Sigel October 7, 2024

So now when I log:

Now is: {{now.jiraDate}} and Discovery Kickoff is {{issue.customfield_10239.match(".*start.*([0-9]{4}-[0-9]+-[0-9]+)").toDate.jiraDate}}

I get:

Now is: 2024-10-07 and Discovery Kickoff is 2024-08-01

and when I log:

Date Diff is: {{now.JiraDate.diff(issue.customfield_10239.match(".*start.*([0-9]{4}-[0-9]+-[0-9]+)").toDate.jiraDate).days.abs}}

I get:

Date Diff is:

What am I still missing?

 

Adam Sigel October 7, 2024

Removing the `.jiraDate` did it! 

Date Diff is: {{now.diff(issue.customfield_10239.match(".*start.*([0-9]{4}-[0-9]+-[0-9]+)").toDate).days.abs}}

gives me:

Date Diff is: 67

Thank you!

Like • 2 people like this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
atlassian, out of office, loom, confluence, async collaboration, meeting recaps, remote teamwork, team alignment, knowledge sharing, AI-powered notes, productivity tools, workforce continuity, teamwork collection

Put your meeting notes on autopilot with Loom + Confluence

AI-powered meeting notes keep work moving even if you’re out of the office. Enjoy your well-deserved time off and return refreshed, confident you’ll catch up in no time.

Learn more
AUG Leaders

Atlassian Community Events