UPDATE: See the accepted answer at the bottom of the accepted thread.
Hello All,
I am trying to calculate fractional business days between two date/time fields. I have gotten it to work for calendar days (see below), but I cannot make this work between two date/time fields for business days.
{{#=}}ROUND({{issue.customfield_11111.diff(issue.Resolved).millis}} / (1000*60*60*24), 3){{/}}
Example:
I tried to put businessDays in place of millis and removed the calculation at the end but I cannot get the value to be in fractional days. Can anyone help me with solving this problem?
Thanks,
Austin
There is an old suggestion to support this in rules but I could not find a more recent one in the public Jira backlog: https://codebarrel.atlassian.net/browse/AUT-62
I believe the business days calculations are always integers and for Monday-Friday, 9 am to 6 pm. These behaviors are often limitations when your working days are different, or when you want to remove holidays.
There are a couple of work-arounds, depending on how accurate of an answer you need:
Kind regards,
Bill
Hey @Bill Sheboy, I somehow didn't see your response here. Thanks so much for the prompt response. I won't have the resourcing to complete the first option (very accurate results) but I would like to implement the less accurate option. Can you help me with the syntax with the business days diff in my scenario in the initial question? How does my example in the prompt change with business days diff?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Curious timing you just asked about this again...I just did this calculation in a spreadsheet to build a support ticket on the built-in, Atlassian interpretation of a control chart, possibly having an error.
My basic calculation idea was:
I have not tried implementing this in a rule yet. If you get stuck, please let me know and I will create a test rule for it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hey, @Bill Sheboy I was able to follow you on the business days diff and subtract the start and end days. So for example I did a test date range of 14 days, it had 4 weekend days included and then I subtracted 2 to get 8 days. From there I am stuck trying to calculate the fractional days on the start date and the end date. You can see what I have below (it does not include the fractional days. I assume I add (+) two forms of diffs after the -(2) below? But what is the smart value I use? Am I using the date diff format repeated twice? For instance, my thought is it would involve a diff of the following but I don't know the syntax for grabbing the start of a day or end of a day off of a date field value. Can you assist with that?
{{#=}}ROUND({{issue.customfield_11111.diff(issue.Resolved).BusinessDays.abs}} - (2)}}, 3){{/}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
First, three things to consider for implementation of this approach:
The first and second ones help with implementation, and the third with complexity and the number of test cases. Such as:
I highly recommend drawing some timeline, line charts to plot your test cases before starting.
Now onto some how-to stuff:
After you have handled special cases with if/else conditions, I recommend using three created variables for the three parts to add: starting day, middle days, and finishing days. We already covered middle days (date diff of business days, minus 2)
Let's assume you want to count whole days as business days for the clock. The finishing day example would be the difference between the beginning of day and finishing work, or Resolved...which just the hours in the day. This will be in UTC so please adjust to your time zone, as needed.
{{#=}}{{issue.Resolved.format("H")}} / 24{{/}}
If instead you wanted to start at a specific time of day, you would substract that value and divide by your length of day. Let's assume a start of day at 8am, and a 9h day, including 1h for lunch. Again, please adjust for time zones.
{{#=}}{{issue.Resolved.toStartOfDay.diff(issue.Resolved).hours.minus(8)}} / 9 {{/}}
The starting day calculation would be similar, except measuring from the beginOfWork datetime value to the end of the day.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey @Bill Sheboy, thanks for the detailed answer. Let me try to add some answers to your questions.
I do not want to start or end at a specific time during the day. I essentially want to cover Monday - Friday 24 hours a day as we have people all over the world (Eastern Europe, South America, North America, etc.). So essentially I only want to have the "clock stop" Saturday at midnight and have the "clock start" back up Monday at midnight. I hope that simplifies this.
So if this is the case it looks like the below would be the format for the ending day:
{{#=}}{{issue.Resolved.format("H")}} / 24{{/}}
Starting day wouldn't need to be explicitly stated since it is already part of the middle days.
Middle days would be:
{{#=}}ROUND({{issue.customfield_11111.diff(issue.Resolved).BusinessDays.abs}} - (2)}}, 3){{/}}
And then all together would be:
{{#=}}ROUND(({{issue.customfield_11111.diff(issue.Resolved).hours.abs}} / 24) - (2) + {{#=}}{{issue.Resolved.format("H")}} / 24{{/}}, 3){{/}}
After doing all of this there are two problems that I am not sure how to resolve.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The -2 days I noted was to subtract the first and second days in the entire range, and was unrelated to weekends. The use of businessDays in the diff takes care of the weekends.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Bill Sheboy ahh I see now. Ok so I have iterated on the solution and below is what I have in place (ill create variables at the end to clean it up). I am getting answers that a correct (within about 10 minutes).
{{#=}}ROUND({{issue.customfield_11111.toStartOfDay.diff(issue.Resolved.toStartOfDay).businessDays.abs}} - 1 + {{issue.Resolved.toStartOfDay.diff(issue.Resolved).hours}} / 24 + {{issue.customfield_11111.toStartOfDay.diff(issue.customfield_11111).hours.minus(24).abs}} / 24, 3){{/}}
Details:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Bill Sheboy I have seen you on many of these threads, hoping you can assist here. thanks in advance!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.