Forums

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

Calculo de tiempo y resta.

Andrés Gutiérrez Flores
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 21, 2025

Buenos días,

Estoy intentado hacer lo siguiente en un tipo de issue llamada Intervención.
En la intervención hay los dos siguientes campos:

- Fecha inicio intervención -> customfield id = 14293

- Fecha fin intervención -> customfield id = 14295

Entre estos dos hago una automatización que calcula el Tiempo de intervención que es otro campo con customfield id = 14300, donde se realiza lo siguiente:
{{customfield_14293.diff(customfield_14295).abs}}, y en la issue muestra por ejemplo, 

9 hours 30 minutes.

Luego tengo otro campo; Exceso de horas -> customfield id = 14351, donde quiero que calcule el Tiempo de intervención menos 3 horas y media, es decir, en el ejemplo anterior de 9 hours 30 minutes debería de guardar y mostrar en el campo Exceso de horas :
6 hours o en el formato de 06:00
Hasta ahora el guardar y calcular el Tiempo de intervención lo hace perfecto, pero al querer calcular el Exceso de horas da error.
Gracias por la ayuda

2 answers

1 vote
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 21, 2025

Hi @Andrés Gutiérrez Flores -- Welcome to the Atlassian Community!

The date / time diff() function returns a text value in the selected units, such as hours.  In your case, you are allowing it to use the absolute value format and then default to "prettyPrint" format to get "9 hours 30 minutes".

 

But that value cannot be used in a math operation.

The solution approach depends upon the type of your Intervention Start Date and Intervention End Date custom fields:

  • If they are date / time picker fields, you could first subtract the time from the second value before performing the difference.  For example:
    • {{issue.customfield_14293.diff(issue.customfield_14295.minusMinutes(210)).abs}}
    • Please note well this uses minusMinutes(210) rather than minusHours(3.5) because those functions always take an integer parameter
  • If they are dates only, you will need to pick times for each date value before performing the minus operation.  Otherwise they will likely assume the start of day, but that will become out of your control.  Explicitly setting the values is better to reduce uncertainty.

 

Kind regards,
Bill

0 votes
Valerie Knapp
Community Champion
May 21, 2025

Hi @Andrés Gutiérrez Flores , welcome to the Atlassian Community and thanks for your post. 

Please can you share the automations you are using for this? 

We would ideally like to see the rule or rules and the audit log so we can see what the error is. 

Looking forward to getting some more information so we can assist.

Best wishes

Suggest an answer

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

Atlassian Community Events