Forums

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

JMWE calculate difference between two dates

Rosana Casilli
Contributor
October 12, 2021

Good afternoon all!!

I am trying to find out how to calculate the difference betwen two dates field and use the result to set another field number data type using JMWE set fields post function

Does anybody know how to do it?

 

Thanks in advance

Ro

2 answers

1 accepted

2 votes
Answer accepted
David Fischer
Community Champion
October 12, 2021

On Jira Cloud, you can use the date('diff') Nunjucks filter, as described here: https://innovalog.atlassian.net/wiki/spaces/JMWEC/pages/108200221/date+filter#datefilter-Datecalculations

For example:

{{ issue.fields["End Date"] | date('diff', issue.fields["Start Date"], 'days') }}
Rosana Casilli
Contributor
October 12, 2021

Thank you David! I didn't know how to used that filters! it worked!

Channakesa Chindanur August 5, 2023

Hi David, 

Even i am looking for the same field to calculate the difference between two dates in my Jira ( Data Center) we have a addon like Xray & JMWE, Does will work to use above script?

Thanks in advance

Chenna

David Fischer
Community Champion
August 5, 2023

Hi @Channakesa Chindanur 

the syntax is different on Server/DC. You can use the secondsBetween and workdaysBetween global functions, as documented here: https://appfire.atlassian.net/wiki/spaces/JMWE/pages/78055921/Groovy+Variables+and+Functions#secondsBetween(Date-from%2C-Date-to) 

For example:

secondsBetween(issue.get("Start Date"), issue.get("End Date"))

which returns a number of seconds, or 

secondsBetween(issue.get("Start Date"), issue.get("End Date")) / 86400

to return a number of days.

Like Channakesa Chindanur likes this
Channakesa Chindanur August 5, 2023

Hi David,

 

Thanks for the quick response, i just going thru that above URL and it's mentioned Seconds between (Date,from and date) variable,  where do i need to add  groovy script in JMWE addon, it could help to provide the steps to use functionality .

Thank You,

Channakesa Chindanur

David Fischer
Community Champion
August 6, 2023

It depends on what you're trying to achieve. Where do you need that calculation?

Channakesa Chindanur August 6, 2023

Hello,

In Jira Data Center! to add a filed using between two value dates as i given below example, This we wanna try in the Jira Issues dash board to get the time spent value field.

Screenshot 2023-08-06 220013.png

David Fischer
Community Champion
August 6, 2023

In that case what you want is to create a calculated duration field using the JMCF app. 

Channakesa Chindanur August 8, 2023

Hi David,

We have a one issue type 'text execution' and we need to add one custom filed to add time elapse between two dates on each issue eg: above mentioned image is Begin date and End date in that we want how much time has been spent, think so we don't have a default CF.

David Fischer
Community Champion
October 12, 2021

Unfortunately, Rosana is on Jira Cloud.

Fabian Lim
Community Champion
October 12, 2021

In that case you may have to play with the other scripted function. https://innovalog.atlassian.net/wiki/spaces/JMWEC/pages/1501265949/Build-your-own+scripted+Post-function 

I haven't used it myself but there are some examples in the links.

Rosana Casilli
Contributor
October 12, 2021

Thank you all!! I tried the solution @David Fischer  suggested and it worked. I am still learning to use JMWE 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events