Restar 2 fechas

Wilber Ballestero August 16, 2023

Buena tarde comunidad, he creado 2 campos personalizados en mi incidencia, 1 se llama fecha 1  y el otro se llama fecha 2, fueron creados con la opción "Marca de tiempo"; ¿existe alguna forma de "restar" las 2 fechas para saber la cantidad de horas que hay entre ellas y que este dato se almacene en un tercer campo personalizado?

Muchas gracias.

1 answer

1 accepted

0 votes
Answer accepted
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 16, 2023

Hola @Wilber Ballestero ,

Sí, esto se puede hacer usando la funcionalidad "Automatización para Jira".

https://support.atlassian.com/cloud-automation/docs/jira-cloud-automation/

Crearía una regla para hacer esto. Debería decidir un disparador para la regla. ¿Desea ejecutar esto en un conjunto de problemas (seleccionados por JQL) de forma regular? ¿O desea ejecutar la regla cada vez que cambie uno de estos campos de fecha?

Puede utilizar la función "diff" descrita en la siguiente documentación:

https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/#--

Háganos saber si necesita orientación más específica.

 

---

Hello,

Yes, this can be done using the "Automation for Jira" functionality.

https://support.atlassian.com/cloud-automation/docs/jira-cloud-automation/

You would create a rule to do this. You would need to decide on a trigger for the rule. Do you want to run this against a set of issues (selected by JQL) on a regular basis? Or do you want to run the rule each time one of these date fields change?

You can use the "diff" function described in the following documentation:

https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/#--

Let us know if you need more specific guidance.

Subtract 2 dates

Good afternoon community, I have created 2 custom fields in my incident, 1 is called date 1 and the other is called date 2, they were created with the "Timestamp" option; Is there a way to "subtract" the 2 dates to know the number of hours between them and have this data stored in a third custom field?

Thank you so much.

Wilber Ballestero August 17, 2023

Muchas gracias por la respuesta, he logrado hacerlo parcialmente;

El código usado fue este:

{{[date1].diff([date2]).[unit]}}



1) Cómo puedo setear/configurar "date1" y "date2" con mis campos, por ejemplo, mis 2 campos se llaman "fecha 1" y el otro se llama "fecha 2", es decir, ¿cómo accedo a los campos de mi incidencia?

 

He hecho esto y no ha funcionado:

 

{{[fecha 1].diff([fecha 2]).[unit]}}

Gracias.

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 17, 2023

Muestre toda su regla de automatización y los detalles del paso en el que está utilizando el cálculo.

Una regla de automatización generalmente se desencadena por un evento en un problema.

Cuando desee acceder a los campos del problema que desencadenó el evento en cálculos como este, debe usar "valores inteligentes". Puede encontrar información sobre valores inteligentes aquí:

https://support.atlassian.com/cloud-automation/docs/smart-values-in-jira-automation/

En la documentación para obtener la diferencia entre dos fechas, el estándar para la documentación es mostrar entre corchetes los elementos que deben reemplazarse. Cuando reemplaza el valor, también debe eliminar los corchetes.

Combine esto con la información de la documentación de valores inteligentes, y la declaración se vería así:

{{asunto.fecha 1.diff(asunto.fecha 2]).días}}

También debe reemplazar [unit] con el tipo de período de tiempo en el que desea que se muestre la diferencia, como minutos, horas o días.

 

---

Please show your entire automation rule and the details of the step where you are using the calculation.

An automation rule is usually triggered by an event in an issue. 

When you want to access the fields of the issue that triggered the event in calculations like this you need to use "smart values". You can find information about smart values here:

https://support.atlassian.com/cloud-automation/docs/smart-values-in-jira-automation/

In the documentation for getting the difference between two dates, the standard for the documentation is to show elements that have to be replaced surrounded by square brackets. When you replace the value, you also have to remove the square brackets.

Combine this with the information from the smart values documentation, and the statement would look something like this:

{{issue.fecha 1.diff(issue.fecha 2]).days}}

You also need to replace [unit] with the type of time period you want the difference to be shown as, such as minutes, hours, or days.

 

Thank you very much for the answer, I have managed to do it partially;

The code used was this:


{{[date1].diff([date2]).[unit]}}

 

1) How can I set/configure "date1" and "date2" with my fields, for example, my 2 fields are called "date 1" and the other one is called "date 2", that is, how do I access the fields of my incidence?

 

I've done this and it didn't work:

 

{{[date 1].diff([date 2]).[unit]}}

Thank you.

Wilber Ballestero August 17, 2023

Claro, está así:

 

- Cuando una incidencia transiciona de un lugar a otro

Screenshot 2023-08-17 at 10.02.56.JPG

entonces actualiza el campo descripción con la resta de los 2 campos

 

Screenshot 2023-08-17 at 10.02.58.JPG

 

Los campos son estos:

Screenshot 2023-08-17 at 10.06.10.JPG

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 17, 2023

Hay un corchete adicional en el valor que debe eliminar.

Screen Shot 2023-08-17 at 9.17.32 AM.png

Además, debe utilizar los nombres de los campos o sus identificadores de campo. Desde la imagen de la pantalla indicas que los nombres de los campos son:

Fecha en la que se creo el trabajo Pre-Produccion

Fecha en la que se inicio el trabajo Pre-Produccion

Debe usar el nombre de campo completo o usar el identificador de campo. Este artículo proporciona información sobre cómo encontrar el identificador de campo:

https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/

También tenga en cuenta que está configurando un nuevo valor para el campo Descripción. No está agregando texto a lo que ya está allí. Está reemplazando el texto existente por completo con el nuevo texto.

Si desea agregar su nuevo texto, colóquelo en una nueva línea antes o después de su nuevo texto para asegurarse de que también se mantenga el texto original:

{{issue.description}}

 

 

---

There is an extra square bracket in the value which you need to remove.

Additionally you need to use the names of the fields or their field identifiers. From the screen image you indicate the field names are:

Fecha en la que se creo el trabajo Pre-Produccion

Fecha en la que se inicio el trabajo Pre-Produccion

You need to use the full field name, or use the field identifier. This article provide information about how to find the field identifier:

https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/

Also note that you are setting a new value for the Description field. You are not appending text to what is already there. You are replacing the existing text entirely with the new text.

If you want to append your new text then put this on a new line before or after your new text to ensure the original text is also kept:

{{issue.description}}

Sure, it's like this:

 

- When an incident transitions from one place to another

then update the description field with the subtraction of the 2 fields

The fields are these:

Wilber Ballestero August 17, 2023

¡Logrado!, muchas gracias.

Like Trudy Claspill likes this
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 17, 2023

De nada. Si sus preguntas han sido respondidas satisfactoriamente, considere marcar la Respuesta como Aceptada.

Wilber Ballestero August 21, 2023

Buenas tardes equipo, una consulta relacionada a este tema:

¿Cómo puedo hacer para que el valor que se escribirá en el campo "Tiempo en ESPERA" se sume al existente en ese campo?

Gracias.

Screenshot 2023-08-21 at 13.48.29.JPGScreenshot 2023-08-21 at 13.48.26.JPG

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 21, 2023

Puede usar la sintaxis matemática que se muestra en la parte superior de esta página:

https://support.atlassian.com/cloud-automation/docs/jira-smart-values-math-expressions/

Donde he colocado "X", sustituya todo el valor inteligente que ha creado para calcular el valor de la diferencia, incluidas las llaves.

 

{{#=}}{{issue.Tiempo en ESPERA}} + X{{/}}

 

---

You can use the math syntax show at the top of this page:

https://support.atlassian.com/cloud-automation/docs/jira-smart-values-math-expressions/

Where I have placed "X" substitute the entire smart value you have created to calculate the difference value, including the curly braces.

Good afternoon team, a question related to this topic:

How can I make the value that will be written in the "WAIT Time" field add to the existing one in that field?

Thank you.

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