Using CURRENT DATE (no time component) in a date range calcualtion?

Jordan Pflum January 12, 2014

Hello there,

I have successfully been using the following HTML calculation for a Calulated Number Field via JIRA Misc Custom Fields to return the range between two dates, which are the custom field IDs in this case:

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

I derived this formula from another forum post on a related topic I saw which was using the following calculation:

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

I am wondering if it is possible to use as a variable in calculations like these the CURRENT DATE (no time component)? So this would be a variable the value for which would be changing every day. Is it possible to include such a variable in an HTML calculation like this, and , if so, what is the syntax?

Thank you!

2 answers

1 accepted

2 votes
Answer accepted
David _old account_
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.
January 12, 2014

You can use "new Date()" to return a Date object representing NOW. If you want to use it in a formula similar to the one in your example, this will do:

&lt;!-- @@Formula: (issue.get("customfield_11618")==null ? null : (issue.get("customfield_11618").getTime() - (new Date()).getTime()) / 1000 / 3600 / 24) --&gt;

Jordan Pflum January 12, 2014

This works - thanks a lot!

CollinM March 8, 2017

Thanks David!

0 votes
FLopez August 25, 2014

is there a way to calculate the last day of a given month? (so if I create the issue today, I would like to have the due date as the last day of this month

Phillip Ponzer [Cprime]
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.
August 25, 2014

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events