Forums

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

Calculated Date/Time Field - Formula To Add 30 Calendar Days?

Jason Rogers
Contributor
February 21, 2019

Hi, 

I have Jira Misc Custom Fields, and have created a custom calculated Date/Time field which I would like to populate with the date, 30 calendar days from when the issue is created. 

This is what I am using in the description at the moment...  

<!--@@Formula: DateTime added = dt.plusDays(30); -->

<!-- @@Format: DATE -->

I have attempted a few different variations of this and sadly not getting anywhere. If anyone knows of something obvious I am missing, or better yet knows the formula that works, I would love to hear from you! :)

Cheers

J

 

 

1 answer

1 accepted

1 vote
Answer accepted
David Fischer
Community Champion
February 21, 2019

I assume you're using JMCF 1.7 (in 2.x, you'd be using Groovy and the new editor).

Try this:

<!--@@Formula: new Date(new Date().getTime() + 30*24*3600000L) -->

<!-- @@Format: DATE -->
Jason Rogers
Contributor
February 21, 2019

Back of the net!

Thank you very much @David Fischer 

Capture.JPG

Jason Rogers
Contributor
March 5, 2019

Hi @David Fischer 

Do you know what changes I would need to make to the above to SET the date to 30 days? 

At the moment I have noticed that the formula gets the date 30 calander days from the current date, but will keep changing it everyday. 

I have tinkering around with it a little, but no joy yet..

David Fischer
Community Champion
March 5, 2019

Hi Jason,

the value of a calculated field is, by definition... calculated. Not stored. If you need a custom field to store a date that you calculate during a transition (or issue creation), you need a standard Date Picker or Date/Time Picker field, and a post-function, such as JMWE's Set Field Value post-function, to set its value during the transition to the following Groovy Expression value:

new Date() + 30
Jason Rogers
Contributor
March 5, 2019

Ahh ok, makes sense. Thanks for your help!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events