Unable to perform DateDiff between Customer Date Picker and Now

nick.pearson
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 16, 2024

Hi

I have a custom field which is a Date Picker field "Brag Last Updated" (custom field 11518) allowing a date range to be entered.  An example of the content is 

{"start":"2024-11-01","end":"2024-11-30"}

I want to work out the difference between the custom field 11518 above and {{now}} in days.  Because the date picker contains a "start" and "end" date I want to only use the "start" date. I have tried various forms of the DateDiff function such as the following but they do not work:

{{issue.customfield_11518.diff({now}).days}}

Presumably the issue relates to the Date Picker (customer field 11518) containing 2 dates "start" and "end" and the the {{Now}} is a date time.  I can reformat the {{now}} to a date only field using {{now.jiradate}}. But cannot find a way to convert the customfield 11518 to return a single date for use in the datefiff.

I have read a lot of previous articles but not yet found the solution.  Can you help pleas

1 answer

1 accepted

0 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 16, 2024

Hi @nick.pearson -- Welcome to the Atlassian Community!

That is the date format used by Jira Product Discovery (JPD), and the values are plain text in automation rules.  Thus text functions must be used to extract the value needed (e.g., "start"), and converted using toDate before the diff() can occur.

For example:

{{issue.customfield_11518.match(".*start\":\"(.*)\",.*").toDate.diff(now).days}}

 

Kind regards,
Bill

nick.pearson
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 17, 2024

Hi @Bill Sheboy  thank you for taking the time to help me and for your suggestion. It worked perfectly. 

 

Kind regards

 

 

Nick

Like Bill Sheboy likes this
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 17, 2024

Awesome; I am glad to learn that helped!  Please consider marking this question as "answered" to help others with a similar need find solutions faster.  Thanks!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events