Hello,
I'm looking for a solution to convert number to time (d/h/m/s)
I was following this article to calculate time spent in the pending status. The result is a numeric number.
Is there a way to get convert the result to d/h/m/s?
Thanks for any suggestion.
When using the diff() function on two date (or date / time) smart values, you may use the prettyPrint unit of measure to make that human-readable. For example:
{{issue.created.diff(now).prettyPrint}}
Kind regards,
Bill
Hello Bill,
Thank you for your reply.
But I get this error:
Error rendering smart-values when executing this rule:
Too many numbers or variables:
For this:
{{#=}}{{NumberOfSeconds}} + {{IF(TotalPendingSeconds,TotalPendingSeconds,0)}}{{/}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The syntax of the if() expression you are trying is this:
{{if(someBooleanExpression, valueToReturnForTrue, valueToReturnForFalse)}}
https://support.atlassian.com/cloud-automation/docs/jira-smart-values-conditional-logic/#if
But you appear to be passing a number for the Boolean expression.
If changing that does not help, please post an image of your complete rule, images of the relevant actions / conditions / branches, and of the audit log details showing the rule execution. Those will provide context for what you are observing. Thanks!
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 following this KB: How to use automation to get the time an issue was in a status | Jira | Atlassian Documentation
Under Saving Cumulative Time part, I'm using
{{#=}}{{NumberOfSeconds}} + {{IF(TotalPendingSeconds,TotalPendingSeconds,0)}}{{/}}
The result is in seconds. Far as I understood, prettyPrint does not work here in the expression (at leas it was empty for me).
Then I tried to create a variable, do the mat there and use Edit issue to update the field with the value and prettyPrint
If I remove prettyPrint from the math, it works:
Any thoughts?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The date / time diff() function's units of measure are for date / time field differences. They cannot operate on arbitrary number values, as created by that article's suggestions. And so prettyPrint cannot work on just a number.
If you expect issues to only be in a status / column one time, try using just the diff on the date / time values.
But if you expect the issues to be in multiple times and want the cumulative value, as that article describes, consider either manually performing the calculations with math functions (for each unit, days, hours, minutes, and seconds) or use a marketplace addon for the reporting.
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.
Hi, @Csaba Vertessy
What is original value, that you try to convert to time?
Is it numeric field, ot time duration field, like logged time?
You can use smart value math functions, to convert number to date units. Here are some examples:
Seconds
{{timetracking.timeSpentSeconds}}
Minutes
{{#=}}{{timetracking.timeSpentSeconds}} / 60{{/}}
Hours
{{#=}}{{timetracking.timeSpentSeconds}} / 3600{{/}}
Days
{{#=}}{{timetracking.timeSpentSeconds}} / 3600 / 24{{/}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Evgenii ,
The result is the diff between two transition dates.
For eg.; the result is 59,843 (in seconds).
I want to convert this to human readable value like: 0d 16h 37m ...s
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Got it. Then you can use smart values like:
{{#=}}{{timetracking.timeSpentSeconds}} / 3600 / 24{{/}}d {{#=}}{{timetracking.timeSpentSeconds}} / 3600{{/}}h {{#=}}{{timetracking.timeSpentSeconds}} / 60{{/}}m {{timetracking.timeSpentSeconds}}s
Use your smart value instead of mine {{timetracking.timeSpentSeconds}}, which I showed for example
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Evgenii ,
thanks for you suggestion, however, your dividing provides the same result for each math. So its not converting.
Thanks anyway, I appreciate it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dividing in 4 pieces is not a very good solution. Numbers are not round and it's required to calculate correctly hours/minutes/secons (in my example it's not made)
Try to use @Bill Sheboy advice. It must work. I made a test rule, and it shows required formatting by default
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Today only! Share what you’re the most excited about for Team ‘25 or just dance out the beginning of a new quarter with us.
Comment the postOnline forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.