Trying to calculate the difference between two different dates and output the number of days in another field within Jira. Then how to set a value to 1 when the number of days equal Zero.
Hello @Charles Brooks
Welcome to the Atlassian community.
Without a third party app you would need to use an Automation Rule to accomplish that. Are you familiar with Automation Rules?
https://support.atlassian.com/cloud-automation/docs/jira-cloud-automation/
You may have to work with a Project Admin or a Jira Administrator to get the rule constructed if you don't have sufficient permissions.
If you are unfamiliar with the feature you can find free, on-demand training from Atlassian at
https://university.atlassian.com
With an automation rule you could use the diff function to get the differences between two date fields.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The issue, I'm having is that I need a specific Date field within my project, to do the calculation. For example when I use the Smart Value, and type for the Field Due Date, I get multiple choices and don't know which one to use.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Charles Brooks -- Welcome to the Atlassian Community!
If there are multiple fields with the same name causing confusion (which is a different problem), you can identify the needed one using this how-to article:
https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/
The essential steps are to identify and example issue with your field, use a browser tab to call the REST API, search on the page for your field, and the likely use the custom field ID to select the correct one.
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your reply, the date field I'm trying to use is a System Field called "Due date", maybe I'm better off creating a custom date field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Due Date is one of the pesky built-in fields that has multiple smart values. Please try this one in your expression:
{{issue.duedate}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you provide a screen image of where you are seeing the multiple choices?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have 7 choices for the Field Due date, since this field is a system field in Jira.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for that additional information.
Can you provide a more complete screen image? It seems that you might be using some of the AI/helper functionality to help you construct the rule. I am not using any of that functionality, so I don't get the same screen.
Or you can just try the smart value suggested by @Bill Sheboy . He did provide the correct value if the field you are trying to access is the system provided Due Date field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have tried using the system field Due Date, inside my formula but I still can't get it to work. I must be doing something incorrectly here.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Charles, what do you observe happening that is not working as expected?
And, would you please post:
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Charles Brooks
I see a typo in the smart value in your Edit Issue action.
You are using
{{issue.customfield_11957}.diff(issue.duedate).days}}
Notice the "}" character immediately to the right of the "7". You need to remove that character.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Now it's working, but when I have a Due Date and Completion on the same day I get a value of zero. I need the value to say 1 , not Zero, how would I do that.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The diff() function is returning the correct value. If the two date fields are the same, the difference is 0.
If the dates one day off (i.e. today and tomorrow), would you want to record a value of 1 or 2?
Have you considered all your scenarios?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sometimes tasks are created today and I can complete the same day, so I need to show that it took 1 day, not 0 days.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
After you have defined all possible cases for testing, as Trudy suggests, you could use a math expression and the MAX() function to ensure the value is always at least 1.
For example:
{{#=}}MAX(1, {{issue.customfield_11957.diff(issue.duedate).days}} ){{/}}
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Bill for the help, I really appreciate everyone's help on this forum.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I don't see any value in the field called Inspection Time, even though it was successful
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.