I need to display the difference between two dates as number of years. How to do this using JWT?

Gunasekaran N May 15, 2023

I would like to use this in the post function of my service desk workflow, to update a numeric field based on the two mandatory date fields that have value. Start date and End date are available. The requirement is to populate the numeric field - "Duration in years"

2 answers

1 accepted

3 votes
Answer accepted
Gunasekaran N May 15, 2023

Hi @Thorsten Letschert _Decadis AG_ ,

I used the following formula based on your suggestion. It worked as expected. Thank you!

round(({00012}-{11604})/{YEAR})

Gunasekaran N May 15, 2023

{00012} is the system date-field "Due Date" and {11604} is a custom date-field "Start Date"

2 votes
Thorsten Letschert _Decadis AG_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
May 15, 2023

Hi @Gunasekaran N ,

Assuming that you want to calculate the date difference between those two fields in years, you can try an expression like

({issue.cfEEEEE} - {issue.cfSSSSS}) / {YEAR}

where EEEEEE is the ID of your End date and SSSSS is the ID of your Start date. Add those two using the field picker, and make sure you're using the numeric value without the '%'.

Cheers,
Thorsten

Gunasekaran N May 15, 2023

This was giving syntax error!

The post function that I am using is:

Update parameters of the Mathematical or date-time expression calculator Function for this transition.

However your reply gave me a clue. Thank you

Thorsten Letschert _Decadis AG_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
May 15, 2023

Hi @Gunasekaran N ,

Thanks for your feedback. Could you please accept my answer then?

Cheers,
Thorsten

Suggest an answer

Log in or Sign up to answer