Forums

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

Is it possible to add remaining time to date?

Danil Savushkin September 22, 2021

Dear all,

I am trying to increase the End date of an issue (custom field with "Date" format) with a time, contained in Remaining Estimate field. I have created a temporary variable with such value:

{{issue.fields.timetracking.remainingestimate}} (lets call it "EstimateTime"

which gives me something like "1h 40m"

As I try to add this to my custom field date using {{customfield_10000.plusDays(EstimateTime)}}, nothing happens. Of course, I need to put Days in this expression.

I tried to convert "EstimateTime" to days using{{issue.fields.timetracking.remainingestimateDays}}, but it doesn't works.

I also tried to convert it like:

{{#=}}({{issue.fields.timetracking.remainingestimateSeconds}}) / 86400{{/}}

and it worked, but when I try to add it as  {{customfield_10000.plusDays(EstimateTime)}}, it  doesn't work. I also tried using ".round" to receive an integer, but  {{customfield_10000.plusDays(EstimateTime)} also doesn't work with this integer.

Could anyone please provide any tips on how to add estimated time to dates? Is it even possible?

1 answer

1 accepted

0 votes
Answer accepted
Alex Koxaras _Relational_
Community Champion
September 22, 2021

Hi @Danil Savushkin and welcome to the community!

Hope all is well :)

Really interesting question you've got here! I've played a bit around with an automation...well..actually with all the work prior of creating an automation and it seems that your date field, as you clearly state, is a date field. It doesn't include any time factor. If you take a look at what you get for an issue via API, you will probably see that your fields returns just a date. Now, if you try to add time to your day, it will not work.

So far I managed to make it work for full business days. And I managed to add hours only if you get the date field to another date/time format.

Like I said.. quite interesting topic! I'll let you know of the progress.

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 22, 2021

Hi @Danil Savushkin -- Welcome to the Atlassian Community!

Adding to what Alex notes, unfortunately created variables cannot be used as parameters in automation rule functions yet.  Here is the open issue for that: https://codebarrel.atlassian.net/browse/AUT-2022

A work-around for this is to create a variable to compute your value, and then set it to an entity property.  Entity properties can be used as parameters to functions.  And writing values to the audit log as you proceed can help confirm things are working as you expect.

Kind regards,
Bill

Like # people like this
Danil Savushkin September 23, 2021

Hi @Bill Sheboy 

Thank you! This actually worked, I have created "Remaining Time (Days)" custom field with numeric format, placed this value in it

 {{#=}}({{issue.fields.timetracking.remainingestimateSeconds}}) / 86400{{/}} 

Then I used another variable to convert it to number (maybe should use .round instead)

{{estimateToDay.asNumber}}

and used it as a parameter in function

{{customfield_XXXX.plusDays(customfield_YYYY).jiraDate}}

 It seems to work good enough, going to play around with it 

Like # people like this
Alex Koxaras _Relational_
Community Champion
September 23, 2021

Nice work @Danil Savushkin!

Suggest an answer

Log in or Sign up to answer