Hello everyone,
I am using JIRA Cloud and it's Automation feature. I am stucked at a minor issue someone might have a solution for:
Goal: Calculate day difference from today til a day in future
Formula: now.diff(version.releaseDate).days
The formula works and returns a value. But the result is not correct from a human point of view.
Assume this formula is called during Friday and releaseDate is the upcoming Monday the result of the formula is: 2
As a human I would expect: 3 and interpret 2 as Sunday.
I understand why the formula returns 2. But is there a way to achieve a result of 3?
I didn't found anything about rounding ...
Thanks, Roman
Thanks to @Tony Langlet I found the solution to my problem.
Root cause: The release date comes only with a date value and a zero timestamp (as there is no timestamp to configure).
The value of NOW comes with a date and a timestamp value (non-zero).
Diff both values result in a floating number which than gets converted into an integer . The internal rounding renders the result to be wrong.
Solution: One way to solve this is give the NOW value also a zero timestamp. Then the diff calculation will work out as expected.
Calling
now.toStartOfDay
does the magic.
Full function:
now.toStartOfDay.diff(version.releaseDate).days
Regards, Roman
Hello Roman,
I guess it all depends on how you count.
With the formula that you use would the difference between monday and tuesday be 0? If that's the case you could just add two to the calculation, if you'd like to count the current date and the end date.
(now.diff(version.releaseDate).days) + 2
You could use math and round as well
https://support.atlassian.com/cloud-automation/docs/jira-smart-values-math-expressions/
You could look in to the different date parameters and see if .businessdays works better.
https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/
An example that I use for checking difference in the last change in status is as follow,
{{now.diff(issue.customfield_10021.currentStatus.statusDate.jira.toDate).businessDays}}
I hope that some of the info I shared could be of use.
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.