Forums

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

Automatically set expected Due Date to issue, exclude weekends and holidays

Vrushali Hasbe September 23, 2019

Hi everyone

I am trying to update my expected Due Date from the Created Date.(Created date+5)
I want to exclude weekends (Saturday and Sunday) when calculating the Expected Due Date.
Is there any way to Calculate due date except Saturday, Sunday and holidays??

2 answers

1 accepted

0 votes
Answer accepted
Antoine Berry
Community Champion
September 23, 2019

Hi @Vrushali Hasbe ,

This should be of good help.

Antoine

Vrushali Hasbe September 25, 2019

Hi @Antoine Berry  

Thanks for the solution.

I have use your solution also But i can't able to update due date for issue and also my Due date custom field is present on view issue screen. I have attached the screenshot. please check it and tell me where i am wrong.

Due Date post function1.jpgDue Date Post Function.jpgDue Date Issue.jpg

Antoine Berry
Community Champion
September 25, 2019

Hi @Vrushali Hasbe ,

Please use this script : 


Calendar c1 = GregorianCalendar.getInstance();
c1.setTime(new Date())

for(int i=1;i<=5;i++){
c1.add(Calendar.DAY_OF_MONTH, 1);
if (c1.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY)
c1.add(Calendar.DAY_OF_MONTH, 1);
if (c1.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY)
c1.add(Calendar.DAY_OF_MONTH, 1);
}

c1.clearTime().getTime().toTimestamp()

Antoine 

Vrushali Hasbe September 26, 2019

hii @Antoine Berry 

Thank you very much for your script and it is working fine for me.

Antoine Berry
Community Champion
September 26, 2019

Hi @Vrushali Hasbe , glad it worked out. Please make sure to accept the answer so it can help others too.

Vrushali Hasbe September 26, 2019

Ya sure

0 votes
Andrew
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.
September 23, 2019
Vrushali Hasbe September 23, 2019

Hi @Andrew 

I am using Scriptrunner plugin for Jira plugin.

And also I have tried script that I have found online but it do not work for me.

I want to set due excluding Saturday and Sunday and public holidays

Suppose Today i have created one issue then my due date will be current date+2.
If i create issue on Friday means my due date will be (current date+2) but excluding Saturday and Sunday. means the date present on Tuesday.

Like # people like this

Suggest an answer

Log in or Sign up to answer