How to calculate business days including Bank Holidays?

Anita Domańska January 24, 2022

Hello Community,

We are using Jira Cloud Premium.

I'm trying to calculate duration (working days) between 2 custom date fields (e2e tests start and e2e tests end) using automated rule that inserts this value to another numeric field.

I calculate the number with this rule:

{{issue.customfield_13297.diff(issue.customfield_13298).businessDays}}

However Jira Cloud supports advanced management of working days (adding bank holidays/non-working days) only the Board level and I need my rule to work across one Jira project for all Epics...thus I wondered is there any way to get businessDays of one Board where these days are defined?

Or maybe there is already some known app / solution that I didn't find (I searched a lot) that allows to calculate working days including public holidays between 2 custom date fields?

 

Thank you in advance!

Anita

2022-01-24 14_33_13-Automation - JIRA — Mozilla Firefox.png

1 answer

0 votes
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.
January 24, 2022

Hi @Anita Domańska 

There is no REST API call to get the non-working days for a board, so you may need to either look for a marketplace addon or hard-code the values in an automation rule and use math, list, and smart value filtering functions to count them (and then subtract from the built-in working days diff).

Kind regards,
Bill

Anita Domańska January 25, 2022

Hello @Bill Sheboy  - thanks for quick reply and checking on this.
Can you please advise how I can hardcode non-working dates? I'm not so good with Advanced JSON field edition in automation.

I tried even the simplest one to assign the value (working days amount between two date fields) to my custom field, to avoid situation custom field is renamed - automation stops working. So I thought the best way is to use this advanced script and unique ID of my custom field.

I attached 2 screens - first shows standard way of assigning field - all works, advanced - shows errors: "Error while parsing additional fields. Not valid JSON."

 

2022-01-25 22_28_08-Automation - JIRA — Mozilla Firefox.png2022-01-25 22_27_54-Automation - JIRA — Mozilla Firefox.png

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.
January 25, 2022

Hi, Anita!

Let's break this problem down into pieces:

First, when trying to diff those two custom fields for the dates, try just writing that to the audit log first.  That will confirm if you have the syntax for the date diff correct before trying to update the field.

Next, what I meant for the date comparison was to put your bank holiday date in a created variable as a string (e.g. 2022-01-25) and than use the date compare functions to determine if the holiday is within the range of your start/end date.  If it is, decrease the working days accordingly.

One last thing: in edit issue image you show, you are both changing a field and using the advanced edit for JSON.  Is the "KPI EAD11..." field the same as "customfield_13333"?  If so you cannot do both in the edit so pick one method: without or with the JSON.

Anita Domańska January 26, 2022

Hello @Bill Sheboy !

Great thanks for your hints. I will do as you suggested and will try with the hardcoded holidays values.

To answer your last questions - I use another custom field for this, not the same as KPI EAD11 - as Im aware of the conflict.

 

Thanks,

Anita

Thies Uhlenbruch February 1, 2023

@Bill Sheboy

 

Next, what I meant for the date comparison was to put your bank holiday date in a created variable as a string (e.g. 2022-01-25) and than use the date compare functions to determine if the holiday is within the range of your start/end date.  If it is, decrease the working days accordingly. 

 

It seems that this is not possible and I don't find a practible example to compare a date with a date in a date range

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.
February 1, 2023

Hi @Thies Uhlenbruch 

With the current capabilities/limitations of using created variables in rule functions functions...the only possible work-around I have found for this was chaining math conditions of greater than or equal to (gte) and less than or equal to (lte) on the date: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-math-expressions/ as I recall those accept variables.

Kind regards,
Bill

Suggest an answer

Log in or Sign up to answer