Forums

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

Why compared date result that is less than -14 will always return to -1 ?

Boyd Hong
Contributor
August 17, 2023

Let's say i am editing a field name "DiffDate" 

DiffDate = {{now.compareTo(issue.customfield_10304)}}

now = August 17, 2023
Customfield_10304 = September 1, 2023

 

I expected that the result would return "-15" (minus fifteen), but i notice "-1" instead.

If i change the Customfield_10304 to August 31, 2023, i would get "-14" (2 week earlier from now) which is correct as i expect.

 

I wonder why compared date result that is less than -14 will return to -1 instead?

Kindly let me know if i do it wrong. Thanks guys.

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.
August 19, 2023

Hi @Boyd Hong 

The compareTo() function returns -1, 0, or 1, indicating the ordering of the dates: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/

If you want the days difference, please use the diff() function instead:

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

Kind regards,
Bill

Boyd Hong
Contributor
August 20, 2023

Thanks Bill.

Like Bill Sheboy likes this

Suggest an answer

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

Atlassian Community Events