How can I set Jira automation to create a ticket with a due date of the 2nd Friday every month?
Asked by Kara Nadarajah:

I've created an automation which creates a ticket on the 1st of each month. The ticket needs to be populated with a due date which is the 2nd Friday of that month.

I've not been able to identify how to do this by looking at the existing documentation and questions. Please can someone help?


Answers:
author: Anandhi Arumugam
body: Hi [@Kara Nadarajah](/t5/user/viewprofilepage/user-id/3967719) I believe you have a scheduled trigger that creates an issue on the first day of every month. To the action that creates the issue, you need to set the value for the due date field. You need to choose the due date field from the options. Under the Due Date field, click on pick a date and set the value. Hope this helps.![Automation - Set Due Date.png](https://community.atlassian.com/t5/image/serverpage/image-id/340212iD25A205F834B81F7/image-dimensions/469x265?v=v2 "Automation - Set Due Date.png")

comments: author: Jakub Koc
body: Yeah, you can set there date manually but in that case you would have to change it every month, there is no exact smart value to calculate 2nd friday of the month


author: Kara Nadarajah
body: Thanks, I know how to set the due date but there is no option and no smart value in the documentation for setting '2nd Friday of each month'.


author: Anandhi Arumugam
body: [@Kara Nadarajah](/t5/user/viewprofilepage/user-id/3967719) Can you try something like

```
{{#=}}
startOfMonth().plusDays(
14 - startOfMonth().dayOfWeek().plus(1) % 7
)
{{/}}
```


author: Kara Nadarajah
body: Thanks, i'd be grateful if you could explain what that formula is doing as I don't understand it and would be apprehensive to blindly apply it in case it doesn't work.


author: Anandhi Arumugam
body: The formula uses `startOfMonth()` that gives the first day of the current month. The `dayOfWeek()` gives the day of the week as a number (eg: Monday = 1, Sunday = 7). Then ,the formula calculates the offset needed to reach the first Friday, then adds 7 days to reach the second Friday.   
I recommend that you test this thoroughly before you implement.


author: Jakub Koc
body: Currently what you are trying to achieve may be impossible and you would have to set the date manually, but maybe you can think of something with the idea,  

Scheduled automation that would run once a week on Friday and check if today's date is between 8 - 14 day of the month (using smart value) and do some action at that moment.  

Though if someone needs to fill that out within that time I think setting up some custom SLA with reminders for that specific person or group would be a better solution

comments: author: Jakub Koc
body: [@Kara Nadarajah](/t5/user/viewprofilepage/user-id/3967719) I believe this smartvalue will be answer for you  

{{#if(equals(now.dayOfWeek==5))}}  
{{now.plusDays(7).format("dd/MM/yyyy")}}  
{{/}}

{{#if(not(now.dayOfWeek==5))}}  
{{now.withNextDayOfWeek("FRI").plusDays(7).format("dd/MM/yyyy")}}  
{{/}}

<br />

<br />

Smartvalue searches for the next friday, adds 7 days and prints the date in following format. First part is for when rule would be run at Friday then just add 7 days to that date, second part is for whenever the day when automation is run is not friday, then it would find the next friday, add 7 days to it.   
Hope that helps.  


Tags: cloud

jira-cloud