Calculate Working Day, Business Day in Jira when Ticket is created

Aashutosh Kumar May 3, 2021

Hi All,

I need to calculate Working Day/ Business Day  of the Month, when the Ticket is created.

For Example: If ticket is 

created  3rd May 2021, i.e. Monday, then Working Day=1
created 11th May 2021, i.e. Tuesday, then Working Day=7


I also need to exclude National/Bank Holidays.

Is this possible any how, using JQL,  Calendar, Groovy Scripts?

I was able to calculate working days, but not exactly how I want using below JQL

created >= startOfMonth() and created <= startOfMonth("+7d") and created >= startOfWeek("+1d") and created <= startOfWeek("+5d")

 

2 answers

1 accepted

1 vote
Answer accepted
Aashutosh Kumar May 5, 2021

Finally able to calculate Working days using below method.

 

Trigger: When Issue Created
Then Edit issue Field
"First Business Day" = {{now.firstBusinessDayOfMonth}}
"Created Date" = {{created.jiraDate}}
Re-Fetch Issue Data

IF Issue created on First Businesss Day
Created Date = First Businesss Day of Month
cf[11240] = {{issue.created.firstBusinessDayOfMonth.jqlDate}}
Then
Edit Issue Field -> "Working Day" = 1

ELSE IF Issue created on 2nd Businesss Day
Advanced Compare Condition
[ "First Businesss Day" - issue.created ] = 1
{{issue.customField_11241.diff(issue.created).businessDays}} = 1
Then
Edit Issue Field -> "Working Day" = 2

ELSE IF {{issue.customField_11241.diff(issue.created).businessDays}} = 2
Then
Edit Issue Field -> "Working Day" = 3

ELSE IF {{issue.customField_11241.diff(issue.created).businessDays}} = 3
Then
Edit Issue Field -> "Working Day" = 4

ELSE
<Whatever>
Ravina
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 21, 2022

Hi @Aashutosh Kumar 

Have you used the automation rule for this?

Aashutosh Kumar February 23, 2022

yes

Ravina
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 25, 2022

Hi @Aashutosh Kumar 

I also used the automation rule but I am getting the below error:-

I am using the "Start Date" Field instead of using the "First Business Day" Field.

I am also seeing Smart Values Documentation. but I am not getting the solution.

Capture 2022-02-25 at 18.35.19.png

Matthew Olds May 9, 2022

Have you tried dropping the, "Start Date" = at the beginning of your string? I would try just:

{{now.firstBusinessDayOfMonth}}

0 votes
Dirk Ronsmans
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 3, 2021

Hi @Aashutosh Kumar ,

getting the day of the week might be possible but holidays might be harder/impossible. 

what would your use case be?

if this is for SLA then you can just configure it with a Calendar object to specify working days and Holidays. 

I’d be happy to think along but if u can elaborate a bit on your use case maybe we can think of a way to work this out 

Aashutosh Kumar May 3, 2021

Hi @Dirk Ronsmans 

At least calculating the Working Days even without Holidays would work for me.

I need to calculate if Ticket is created within X working days or not and process it further, like:
 
If Ticket created on Working Day 1
    Then Do X
Else If Ticket created on Working Day 2
    Then Do Y

Is there any possibility to use calendar from SLA?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events