Good afternoon!
I've been looking for and tried various proposed solutions to similar issues but to no avail.
I've set up a series of automations that log the date/time a specific label is added to an issue into a custom field. There are 3 or 4 labels I'm interested in tracking and I've got that working without issue.
What I would like to do next, and where my issues lie, is add fields between them that will display the time taken between the 1st label being added and the 2nd being added in another custom field. The idea is that it will show...
Label 1 added [date][time]
Time between with label 1 added and label 2 added [x] d, [x] h, [x] m, [x] s
Label 2 added [date][time]
Time between with label 2 added and label 3 added [x] d, [x] h, [x] m, [x] s
Issue transitioned [date][time]
Time between label 3 added and issue transitioned [x] d, [x] h, [x] m, [x] s
I can get it to add text into the 'time between' field, but I cannot get diff to work.
I initially tried {{now.diff(issue.customfield_XXXXX)}} within the same rule that the date/time stamp is added but when that didn't work I tried to add a new rule watching for a change on the field and then doing a diff between the 2 custom fields but that didn't work either!
I'm 99% sure I'm just doing something in the wrong order or the wrong place!!
If anyone could help me out/give advice or suggestions, I would greatly appreciate it and save me from pulling my hair out any more than I already have haha. TIA
Hello @Colin Macrae
Its hard to understand what the issue could be without screenshots of the rule and audit log.
I am sharing a screenshot of example below and let us know what is not working.
In my example, I am storing date in the format of YYYY-MM-DD in a custom field. This is a text field.
and I am logging various values for you to refer.
So when I log just {{customfield_11302}}, I get output of date but it is a string. I cannot do date operations on it yet. I have to convert it to date. So thats my second log. {{customfield_11302.toDate}}
As you can see in my third log, I can "format" this date by specifying the sequence (MM/DD/YYYY) in my case.
Finally, to do a diff, I am using the customfield.toDate to calculate the difference.
The diff function takes 2 dates.
Are you trying to subtract days from date? If so you have to use minus operator. See link further below:
Now can you please tell where are you stuck and share some screenshots of audit log like I have above of various fields and what is not working with diff?
That helped a lot actually, the problem was not having the '.toDate'. My wife is an Oracle developer, so I also picked her brains, haha!
For context, I am tracking labels added to an issue to calculate the time to progress through various stages of testing.
For anyone else who may be looking for similar in the future...
The eventual solution comparing a custom field containing a date/time and the current time (when the label was changed to the next stage) and then showing the difference between them is as follows:
{{issue.customfield_10377.toDate.diff(now)}}
Thanks for your time and reply!
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.