Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Calculate Weekend and Holidays

Ravina
Community Champion
February 12, 2022

Hi, I am trying to build Leave Management using Jira service management. I want to calculate weekend days and holidays on the Jira Service Management portal by using a script. for that purpose, I am using the cloud.

2 answers

1 accepted

0 votes
Answer accepted
Alexander Bondarev
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 13, 2022

Hi @Ravina !

I agree with @Pramodh M , it sounds nice. 

But what is your question? Have you already done somethig? Do you have any difficulties?

Ravina
Community Champion
February 13, 2022

Hi @Alexander Bondarev 

I want to create leave management.
by using Jira service management raise requests through the customer portal.
on that form, I used 2 fields start date and end date so I want to calculate only working days.
for e.g I will be raising a request for leave which is 17-02-2022 to 22-02-2022 .so it will count as only 3 days' leave .it will not count Saturday, Sunday, and bank holidays also. by using the cloud, not using confluence and plugin also.

Alexander Bondarev
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 15, 2022

Hi @Ravina !

Got your case, thanks! 

I'm not sure, but I think it is possible using out-of-box Automation. 

You need 3 fields:

- start vacation date (customfield_20001)

- end vacation date (customfield_20002)

- vacation duration (business days)

Then create a rule with trigger "Issue created", then action "Edit issue field", select "vacation duration" and add something like this: 

// The number of business days beeween when the issue was created and today 
{{issue.customfield_20002.diff(issue.customfield_20001).businessDays}}

I got it from the official documentation - Examples of using smart values with dates 

 

Best regards, 

Alexander

Ravina
Community Champion
February 16, 2022

Hi, @Alexander BondarevThanks It's working.

but it was showing the wrong answer. for e.g start date -(17-07-2022) and end date -(25-02-2022)
showing answer is =6
but the expected answer is = 7.
I used this code
{{issue.customfield_10108.diff(issue.customfield_10109).businessDays}}

Like # people like this
Alexander Bondarev
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 16, 2022

Glad to hear that! Cool, that it works. 

Hm. for my Country it will be correct, we have a holiday at 23/02. =) But I got your question and logic.

I need to think a bit. 

Alexander Bondarev
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 16, 2022

It is really strange, because you can configure the similar setting in 3 places:

Configure time tracking 

Configure working days on boards (different types) 

Create and edit SLA calendars 

1st, I think, that you have out-of-box configurations. 

2nd, 3rd - it doesn't matter in our current case. 

 

Try to check another dates... for example, 04/04/22 and 24/02/22. 

And if it will be the same result, I can recommend you to raise a support request on that.

Ravina
Community Champion
February 20, 2022

Thanks, @Alexander Bondarev.   

It has given the same result. I will raise a Support Request.

0 votes
Pramodh M
Community Champion
February 12, 2022

Hi @Ravina 

It works best if you have Confluence with Team Calendars (Confluence Premium)

Please find the reference here

https://www.atlassian.com/blog/inside-atlassian/managing-vacation-days-jira-confluence

Thanks,
Pramodh

Suggest an answer

Log in or Sign up to answer