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

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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

77 views 0 5
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