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

This widget could not be displayed.

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!

This widget could not be displayed.

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 Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

534 views 3 19
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