Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,463,993
Community Members
 
Community Events
176
Community Groups

Add up date/time from 2 custom fields.

Is it possible to add or subtract the date/time from a custom field?

 

What is needed:

When the ticket is moved to a specific status we populate a date/time field (call it field A) using the smart value {{now}}. Later when the ticket moves out of that status, we get the difference between now and when the ticket entered the status, again using smart values.
(The problem is in this part) We need to then add up the difference that we just got to a date/time field (call it field B) which already has a value.

Example:

  1. Field B value is 23.10.2022. 11:00
  2. Ticket moves to the desired status (Field A is filled in with 23.10.2022. 11:00) and stays there for 2 hours
  3. When ticket moves out of the desired status, we now have 2 hours
  4. Add those 2 hours to Field B
  5. Field B value is now 23.10.2022. 13:00

 

Any other suggestions that will solve this problem in a different way are welcome. Using a plugin is not an option.

I was looking into this document but I could not find a solution: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/

Using JSON in the "Edit issue" module in automation rules is also considered.

 

We need all of this to be part of Jira automation since the calculation needs to be done real time for thousands of tickets.

 

Thank you very much for the help.

 

1 answer

1 accepted

1 vote
Answer accepted
Darryl Lee Community Leader Nov 25, 2022

Hi @Danilo Simic - I'm a little confused about the scenario since you're using "Field A and Field B" and it doesn't really make sense to me what you're actually trying to track.

A real world example using the actual fields you are trying to track may lead us to a solution that is simpler.

But just to answer your questions, you can find a difference between now() and a date from another field by using the diff command, as described on that page you referenced.

And you can add time to an existing field by using the plus* command. So I think I achieved what you wanted by creating an Edit Issue action for Field B with the following Smart Value:

{{issue.Field B.plusMinutes(issue.Field A.diff(now).minutes)}}

Please let me know if this works!

Hi @Darryl Lee

Sorry about the confusing explanation.

This will solve my problem. I could not find a smart value expression for adding up two date/time fields.

 

To further elaborate. We now have a field called "Expected Restoration Date" which is a date/time field type. Based on ticket priority we calculate the date/time for "Expected Restoration Date" (Example: If priority is Blocker then we add 8 hours to the ticket created date and fill in "Expected Restoration Date").
However this had the problem that the time in "Expected Restoration Date" field was never updated (it does not account for the time while we are waiting for the customer to provide more information).

So we wanted to include that calculation. The idea we came up with is creating a new field for storing the date/time of when the ticket is moved to the status "Waiting for Customer". Then based on that, once we transition the ticket to some other status we see how much time passed while the ticket was in that status and we add that time to "Expected Restoration Date".

 

Sorry for the text wall and for the bad explanation. I hope this clears things a bit.

Thank you very much for the smart value you provided. I think this is exactly what we need.

Darryl Lee Community Leader Nov 28, 2022

Ah, that makes more sense now. Thank you! I'm glad I was able to help!

Suggest an answer

Log in or Sign up to answer