Using plusWeeks() and nextDayOfWeek(" ") in one arguement
Asked by Chris M.:

Hello everyone,

I want to calculate a field using automation. Starting from the start date, I want to calculate 20 weeks into the future and if it is not a Monday, I want to use the next Monday. Atlassian has introduced the two commands mentioned above, but it seems that they cannot be used in one command. I have tried the following so far:

direkt way:

{{issue.start Date.plusWeeks(20).withNextDayOfWeek("TUE")}}

{{issue.start Date.withNextDayOfWeek("TUE").plusWeeks(20)}}

and indirekt way:

Create variable:

Var: {{varPlusWeek}} which has the following smart value included: {{issue.start Date.plusWeeks(20)}}

And in the next step with extention:

{{varPlusWeek.withNextDayOfWeek("TUE")}}

But nothing has worked. Is it simply not possible, e.g. due to the format or other reasons, or am I making a mistake here? Thank you very much.

Best regards

Chris


Answers:
author: Gaurav
body: Hello [@Chris M_](/t5/user/viewprofilepage/user-id/5574840)

Welcome to the community!!

I have gone through the post and in my understanding, you intend to add 20 weeks from the date of creation. If that is the case, please try the below operation:  
{{issue.created.plusWeeks(20).withNextDayOfWeek("TUE")}}

I have replaced 'start Date' with 'created' which is the smart value to fetch the created date of a ticket.

Please feel free to share your thoughts and feedback on this, including if there is any other usage.

-GG

comments: author: Chris M.
body: Hello [@Gaurav](/t5/user/viewprofilepage/user-id/1248589)

thank you for posting your suggestion. But I realy mean issue.start date. It's a field of Jira by default oder of tempo. Process: The ticket is created in the past. After a while the project lead negotiated the final project start with our customers (start date) and has also to enter the due date manually with the constraints mentioned above. Due to Jiras ability to calculate dates I will calculate the due date automatically.

But I do not understand which Jira has problems with the expression of plusWeeks.withNextDayOfWeek.

Thank you in advance.

Chris


author: Gaurav
body: Thanks for sharing the context [@Chris M_](/t5/user/viewprofilepage/user-id/5574840)

Please see if the below calculation helps:  
{{issue.Start date.plusWeeks(20).withNextDayOfWeek("TUE")}}


author: Chris M.
body: Thanks for your help [@Gaurav](/t5/user/viewprofilepage/user-id/1248589)!

Now, it works!!! :) But I don't understand why. I can also use start Date for a single calculation but if I use it for a chain the is no result. With your help I used Start date and now it is possible to calculate the result.

![jira 3.png](https://community.atlassian.com/t5/image/serverpage/image-id/345098i1463D0329F4E5379/image-size/large?v=v2&px=999 "jira 3.png")![jira 1.png](https://community.atlassian.com/t5/image/serverpage/image-id/345100iD0495E99E39C0AA9/image-size/large?v=v2&px=999 "jira 1.png")![jira 2.png](https://community.atlassian.com/t5/image/serverpage/image-id/345099i27FE4704746C6DB0/image-size/large?v=v2&px=999 "jira 2.png")


author: Bill Sheboy
body: Hi [@Chris M_](/t5/user/viewprofilepage/user-id/5574840)

The reasons some of your early attempts did not work could be...

Smart values are name, spacing, and case-sensitive, and you were using the incorrect case for the field. To learn the correct smart values for a field, please use this how-to article: <https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/>

Variables are text. When you want to use a date saved as text, it must be converted to a "date type" using toDate: <https://support.atlassian.com/cloud-automation/docs/examples-of-using-smart-values-with-dates/#Converting-text-to-dates>

Kind regards,  
Bill


Tags: time