Forums

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

How to get date difference ?

Chasovskikh Kirill
Contributor
May 12, 2022

Hello, friends!

{{issue.customfield_11111.diff(now).months}} - returns integer number of months. 

Is there any way to get float number of month?

 

Or can i get difference between 2 dates without year ? 

F.e. difference between 01/02/20 and 10/02/20 without year = 9 days

 

Thank you in Advance.

2 answers

1 accepted

1 vote
Answer accepted
KC Wong
Contributor
May 12, 2022

Calculating difference in dates... the devil is in the details. 

See this StackOverflow thread for various ways to do so: https://stackoverflow.com/questions/1555262/calculating-the-difference-between-two-java-date-instances 

Scroll down to find the more updated answers. I recommend the one using classes Instant and Duration.  

Chasovskikh Kirill
Contributor
May 13, 2022

thank you!

but is there any way to integrate java code to standart jira cloud without plugins? 

KC Wong
Contributor
May 15, 2022

The easiest way seem to be Script Runner plugin, as Jira itself doesn't provide a way to script. 

1 vote
John Funk
Community Champion
May 12, 2022

Hi @Chasovskikh Kirill 

I don't see anyway that you would be able to do the second one. 

And what do you mean by "float number of months"?

Chasovskikh Kirill
Contributor
May 13, 2022

hi! 

integer - 4

float - 4.5 

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 13, 2022

Hi @Chasovskikh Kirill 

Adding onto John's answers and questions...

What problem are you trying to solve with fractional months?  The fractional values are not comparable for months with differing numbers of days 28, 29, 30, or 31, right?

For your question about just days-differences, do you mean you have two literal date values or that those are from issue fields?  If literal, try putting the dates into created variables first.  If issue fields, why not just do a days diff()?

Kind regards,
Bill

Like John Funk likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events