It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Get business days in calculation

Hey Guys

I'm trying to do a calculation in jira that only includes business hours, but I can't seem to crack the nut. I'm right now using the "JMCF time in status" functionality with a field that just states the raw time. Then i have another field where i'm trying to use a groovy script to show <one thing> if time is <= 8 working hours else <another thing> is that at all possible or should I take another approach? 

The script that i'm currently using is below - it works fine except that it takes raw hours and not working hours.  

import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def field = customFieldManager.getCustomFieldObject(00001);

def value = issue.getCustomFieldValue(field);

if (value < 28800) return "one thing";
else return "another thing";

 Hope you can help me crack the nut - thanks

1 answer

0 votes

Hi Jesper,

you simply cannot use the Time in Status custom field for that, since that custom field type has _no idea_ what "business hours" means. This is actually a complicated problem: the time spent in a particular status is really the time that elapsed between the moment the issue entered the status and the moment it left the status. Calculating the absolute duration is easy, but what about business time? That would require knowing exactly which day is a business day (excluding weekends and holidays), and also when the business day starts and when it ends. Not to mention, this could be different for different users, and it's also dependent on the timezone of the user, etc.

So if you know exactly how to calculate this duration, you can indeed create a Calculated Duration custom field, but you'll need to implement the algorithm yourself based on your own definition of business time.

Suggest an answer

Log in or Sign up to answer

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you