Forums

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

calculated number field - negative values

Tal Kdoshim February 13, 2019

Hi everyone,

I used the following formula:

<!-- @@Formula:

if (issue.get("customfield_10411")==null || issue.get("customfield_10710") == null) return null;

return (issue.get("customfield_10411").getTime() - issue.get("customfield_10710").getTime())/1000/60;

-->

 

To get a calculated number field with the result of:

customfield_10411 - customfield_10710

 

both fields above are date fields.

 

The problem

I got a negative number (-652) for the following values:

customfield_10411= 11/Nov/18 12:34 PM

customfield_10710= 11/Nov/18 11:25 PM

 

Thanks in advance,

Tal

2 answers

1 accepted

0 votes
Answer accepted
Nic Brough -Adaptavist-
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.
February 13, 2019

The number looks wrong to me, as the 11 hour 49 minute difference is 709 minutes, but the negative sign is right - you're taking a larger number away from a smaller one.

Tal Kdoshim February 13, 2019

Hi Nick,

customfield_10411= 11/Nov/18 12:34 PM is bigger than customfield_10710= 11/Nov/18 11:25 PM.

Number should be positive, and the difference here is only 49 min.

Am I missing anything?

 

Thanks

Nic Brough -Adaptavist-
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.
February 13, 2019

Yes, you're misreading the times.  12:34 pm is almost 11 hours before 11:25pm, (pm = post meridian = after noon) so 11:25pm is the larger number.

Nic Brough -Adaptavist-
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.
February 13, 2019

Oh, and my mathematics failed me too - it's not 11 hour 49 minutes, it's 10 hours 51 minutes, i.e. 651 minutes, so I'd say the -652 you're getting is right, as I assume there will be a few seconds to round it up to 652.

0 votes
Tal Kdoshim February 14, 2019

Thanks a lot Nick.

Suggest an answer

Log in or Sign up to answer