Field with time difference between "Created" and a Timestamp.

mfabris
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.
June 9, 2017

Hello everybody

 

I have gone around the answers forum a lot trying to understand how to achieve this.

Basically: I have one field in my issue with a timestamp, which is added with a Post Function  using of course


%%CURRENT_DATETIME%%

The I created a second field, a calculated number field, where I want to calculate the time difference between this time stamp and the created date.

My first idea was to go with 

<!-- @@Formula: issue.get("customfield_27438")==null ? null : ((Double)(issue.get("customfield_27438").getTime() - issue.get("created").getTime())) / 1000 / 3600 / 24 -->

But this is not working because the timestamp is in facts a text field, so i cannot use the getTime() method with it.

I tried to use the getValue() then, but also this is not working.

What could be the solution to make the two values (the text field with the timestamp and the "created" date) so that I can have the field calculate correctly?

Thanks in advance for any help!

 

MF

 

 

 

 

 

 

 

 

 

 

2 answers

1 accepted

0 votes
Answer accepted
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 9, 2017

Why didn't you use a date/time field for the timestamp?

You'd then have two date/time fields that you can take as "milliseconds since base date", subtract one from the other and then divide the result to get it in seconds/minutes/hours etc

1 vote
mfabris
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.
June 9, 2017

Hey Nic! 

Thanks a lot. I had the impression that the post-function could not update the time picker with %%CURRENT_DATETIME%%

But I tried again now and it works. I might have missed something when I tried the first time.

Great, so now it works! I'll go to the next challenge now (excluding the weekends :) )

Thanks a lot for your time!

Have an awesome weekend

 

 

 

Priyanka Yalam August 31, 2020

Hi @mfabris ,

 

Could you please provide the script which you have developed, even i want to find the time difference between the issue created and first comment added. But not able to use the  time stap of commented date.
If you could help me script it would be helpful to me.

Thanks in advance.

Suggest an answer

Log in or Sign up to answer