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

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

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;

This works - thanks a lot!

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

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 13, 2019 in Marketplace Apps

Marketplace Spotlight: Marketing apps for Confluence to keep your teams working on the same page


275 views 0 7
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you