Hi there,
I'm trying to run a date comparison from two values pulled from the changelog by smart values.
{{changelog.Target end.from}} - Output: 2024-11-15
{{changelog.Target end.to}} - Output: 2024-11-13
I suppose that I will need to convert the output to a date format to do some maths...
{{changelog.Target end.from.toDate("yyyy-MM-dd")}}
...returns something but not the output, which I expected:
Output: Fri Nov 15 00:00:00 CET 2024
First question - Why is that the case?
Second question - Is there a way to do some maths with diff to compare both smart values? Everything I'm trying results in an empty output.
Thanks a lot,
Patrick
First thing, I am using Jira Cloud and not the Server version (which your post seems to indicate). Please test with your version for the things I am suggesting. Thanks!
When you added the format string of "yyyy-MM-dd" to the toDate() function that helped with the conversion, and the resulting date / time value appears to be returning in whatever your system and profile are using for date / time formats.
Next, the diff() should be possible if all of the values are actually valid date / times. Would you please show your complete rule, and the specifics of where you are performing the diff? And show the audit log details for the rule execution. Those will provide context to help explain what you are observing.
Kind regards,
Bill
Hi @Bill Sheboy
thanks for taking this up again.
The time format is only specified global. I can't find anything set in addition in my profile.
Here's the rule and all the steps to set variables, mail config and mail output:
Thanks,
Patrick
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
When you create a variable, that is stored as a text value. Those variables need to be converted to date before using the diff() function.
In your create of the "Diff" variable, that would be this, adding the missing units of measure, days:
{{OldTargetEnd.toDate.diff(NewTargetEnd.toDate).days}}
One more thing: when creating variables, I suggest adding a prefix to ensure the name is always unique and will not collide with other fields or rule features. For example, consider renaming that variable from Diff to varDiff by adding a prefix of var to symbolize it is a variable.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Bill Sheboy
I've got no luck with the new diff variable
{{OldTargetEnd.toDate.diff(NewTargetEnd.toDate)}} doesn't work, neither does
{{#=}}{{OldTargetEnd.toDate.diff(NewTargetEnd.toDate)}}{{/}}
Both result in an empty output and the audit log has no errors.
Same with...
{{OldTargetEnd.toDate("yyyy-MM-dd").diff(NewTargetEnd.toDate("yyyy-MM-dd"))}}
{{#=}}{{OldTargetEnd.toDate("yyyy-MM-dd").diff(NewTargetEnd.toDate("yyyy-MM-dd"))}}{{/}}
Thanks and have a nice weekend,
Patrick
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I wonder if the variables with the converted values are still in a format which cannot be directly converted with toDate.
Please try writing the variable to the audit log to confirm the format, and perhaps add more conversion with toDate.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Bill Sheboy
I'm afraid I'll need some support with that. My audit log doesn't say much. Didn't find a way to write something to the audit log yet.
Thanks a lot,
Patrick
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There is a rule Log action which allows writing any value to the audit log when the rule executes:
Writing the variable to the log will help identify what is happening.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Bill Sheboy
thanks for the hint. Unfortunately the audit log also shows an empty variable.
Thanks,
Patrick
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please show images of:
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.
Thanks for that additional information!
FYI: I recommend adding a prefix to variable names for rules and not using anything similar to built-in functions and features, such as "Diff". That will avoid errors / confusion from any typos. For example, perhaps name that variable varDiff.
Also, please add writes to the audit log of the converted, variable values:
Those will confirm the conversions work prior to use in the diff() function. Then re-test your rule.
Finally, would you please post an image of your complete rule? That may provide some context to explain why the value is null.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Bill Sheboy
here's the audit log with the new entries:
...and the rule. The definition of the variables can already be found above:
Thanks,
Patrick
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is quite odd...
Let's try in-lining the entire expression and writing that to the log:
{{changelog.Target end.from.toDate("yyyy-MM-dd").diff(changelog.Target end.to.toDate("yyyy-MM-dd")).days}}
And...I noted some of your diff() function calls are missing the units of measure at the end. Please look to see if your varDiff one is missing the units when the variable is created.
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.
Well, I am out of suggestions. If your rule is matching what the log shows the dates are converting, but only sometimes.
At this point I recommend working with your site admin to contact Atlassian Support: https://support.atlassian.com/contact/#/
After you hear back from them, please post what you learn to benefit the community. 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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.