Forums

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

Seconds in prettyPrint for date/time field diff - Automation for Jira

Marco Baldelli
Contributor
September 27, 2021

Hi there,

I'm currently using two date/time fields and I created a 3rd field (text field - single line) to display the difference in time between the two dates. 

Using the prettyPrint feature from Automation from Jira, I got to the point where I set my diff field with 

{{issue.customfield_123.diff(issue.customfield_456).prettyPrint}}

and this works returning something like

3 days, 4 hours and 12 minutes

Point is, I'm trying also to get the seconds since the two dates are set via REST Api / timestamp and I'd like to have also that level of details, e.g.

3 days, 4 hours, 12 minutes and 37 seconds

I've found this https://community.atlassian.com/t5/Jira-Service-Management/now-diff-issue-created-prettyPrint-output-is-in-negative/qaq-p/1363669#M50598 where it looks like seconds get displayed, but cannot seem to add them.

Does anyone have a similar experience?

 

3 answers

1 accepted

0 votes
Answer accepted
Marco Baldelli
Contributor
October 8, 2021

@John Funk @Bill Sheboy just got a feedback from support, apparently this is an outstanding bug that emerged after the transition to the new issue view.

https://jira.atlassian.com/browse/JRACLOUD-76882

Feel free to add a comment / watch the ticket, it would gather interest for its implementation.

Thank you both for your feedback!

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.
October 8, 2021

Thanks for the follow-up, Marco!

There appear to be several "opportunities" in this area for date/time and the new issue view:

https://jira.atlassian.com/issues/?jql=resolution%20%3D%20Unresolved%20AND%20summary%20~%20%22new%20issue%20view%22%20and%20summary%20~%20%22time%22%20ORDER%20BY%20Key%20DESC

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.
September 27, 2021

Hi @Marco Baldelli 

When I just tried a diff().prettyPrint I got...

Field diff test: {{issue.created.diff(issue.updated).prettyPrint}}

Field diff test: 288 days 17 hours 59 minutes 4 seconds

So...I am seeing the seconds and I wonder where the punctuation you are observing comes from.

Kind regards,
Bill

John Funk
Community Champion
September 27, 2021

Hey Bill - the only think I can think of is because he is using two custom fields. In your example and in the example in the link above, they are both using a system value (created or now). 

Marco Baldelli
Contributor
September 28, 2021

Hi Bill - yes, I'm using two date/time custom field and I set them via Rest API (Jira UI does not allow to set seconds)

About the punctuation: I was just writing down an example, it wasn't an actual copy/paste from Jira :) 

Like # people like this
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.
September 28, 2021

Gotcha, and...Perhaps it's time to chat with your site admin to submit a ticket to support, and confirm if the REST API does/does not support second-granularity, or if this is broken from one of the recent updates: https://support.atlassian.com/contact/#/

Curiously, millisecond and second options are still available for diff() and other date/time functions with advanced edit and automation rules.

When you learn more from the support team, please post back here so the whole community can benefit.  Thanks!

Like # people like this
Marco Baldelli
Contributor
September 29, 2021

Just raised a request, I will let you know the outcome (y)

Like # people like this
0 votes
John Funk
Community Champion
September 27, 2021

Hi Marco,

Not sure that it will make a difference, but you might try this:

{{issue.customfield_123.jqlDateTime.diff(issue.customfield_456.jqlDateTime).prettyPrint}}

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.
September 27, 2021

Thanks, John!  I repeated my test with custom date/time fields, including setting one of them to {{now}} immediately before the test.  After repeated trials I found that the custom field *never* was set to the seconds value: it always truncated (or perhaps rounded.  With a seconds-delta no value is noted.

DevStart=2020-10-29T22:16:00.0+0000; DevDone=2021-09-27T16:35:00.0+0000; Custom Field diff test: 332 days 18 hours 19 minutes

I wonder if this is an API issue, or something else.  (I note that with the new issue view, it is no longer possible to set seconds-granularity.)

@Marco Baldelli have you logged the two values you are comparing to ensure they have seconds-granularity and differences?

Like John Funk likes this
Marco Baldelli
Contributor
September 28, 2021

Hi guys - yes, I think this will end up being the root cause.

I'm currently running a PUT on /rest/api/3/issue/{issuekey} with 

{
"fields": {
"customfield_11947": "2021-09-16T09:11:43.296+0200",
"customfield_11948": "2021-09-16T09:16:15.456+0200"
}
}

but when I run a GET (or I print in the description the actual fields values), I get

"customfield_11947": "2021-09-16T09:11:00.000+0200",
"customfield_11948": "2021-09-16T09:16:00.000+0200",

with seconds and milliseconds set to 0

What's the point of having a timestamp field then? :) 

Like John Funk likes this

Suggest an answer

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

Atlassian Community Events