Change due date of story/issue when epic due date changes, while keeping the difference in days.
Asked by Theresa:

This question has been asked, but I don't understand the answers. I'm new to Jira, and I'm trying to learn how to automate the change of my story/issue due dates when the epic due date changes.

For example, if my epic's due date is August 31st and my story's due date is August 20th, how do I automate it so that if I change my epic's due date to August 29th, my story's due date will automatically change to August 18th? I got to the point where I edit the story/issue due dates when the epic due date changes, but I don't know how to add the delta between the dates.

When value changes for due date

issue type equals epic

branch for stories (or other issues in Epic)

Then Edit issues fields due date

...


Answers:
author: Trudy Claspill
body: Hello [@Theresa](/t5/user/viewprofilepage/user-id/5517412)

Welcome to the Atlassian community.

In order to change the child issue by the same amount as the Epic was changed, you have to calculate the difference between what the Epic's original Due Date was and its new Due Date.

With the Field Value Changed trigger you can reference the fields original value with a special smart value

{{fieldChange.fromString}}

And you can reference the new value with

{{fieldChange.toString}}

<https://support.atlassian.com/cloud-automation/docs/jira-automation-triggers/#Field-value-changed>

<https://support.atlassian.com/cloud-automation/docs/jira-smart-values-issues/#--fieldChange-->

These are stored as strings. To convert them to dates you use the toDate function.

{{fieldChange.fromString.toDate}}

{{fieldChange.toString.toDate}}

To find the difference between two dates you use the diff() function, set the time units you want that difference expressed in.

<https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/#Date-difference--->

{{date1.diff(date2).units}}

In your case to get the difference in days you would use:

{{fieldChange.fromString.toDate.diff(fieldChange.toString.toDate).days}}

At this point you have the days of difference between the Epic's previous Due Date and its current Due Date.

Now you want to apply that difference to the Due Date in the child issue. In your Edit action you use another smart value and function to set the new value of the Due Date for the child issues.

The function to use is plusDays()

<https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/#Date-plus-unit--->

{{date_field.plusDays(# of days)}}

*date_field* is replaced by *issue.duedate*

*# of days* is replaced by the smart value I mentioned above that calculate the difference in days for the Epic's Due Date.

{{issue.duedate.plusDays(fieldChange.fromString.toDate.diff(fieldChange.toString.toDate).days)}}

Put that whole string directly into the entry field in the Edit action for updating the Due date field.

![Screenshot 2024-06-10 at 5.12.46?PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/329020i84544ED910FE604F/image-size/large?v=v2&px=999 "Screenshot 2024-06-10 at 5.12.46?PM.png")

comments: author: Theresa
body: I'm so sorry, but I don't understand this. Can you post the automation?


author: Trudy Claspill
body: What exactly do you not understand?

You have all the steps already.
> When value changes for due date
>
> issue type equals epic
>
> branch for stories (or other issues in Epic)
>
> Then Edit issues fields due date

In your original post you said:
> but I don't know how to add the delta between the dates.

That is the information I provided. You just need to add what I provided in your Edit Issue step.

If that is unclear, show us the automation rule you have created so far.


author: Theresa
body: Sorry, still learning. I was able to get this. Thank you!


author: Trudy Claspill
body: You're welcome!


author: DELACRUZ Guerdly _Gigi_
body: Could you show me the full automation ? I understand what to Put in the edit issues but not sure about the create variable


author: Trudy Claspill
body: Hello [@DELACRUZ Guerdly _Gigi_](/t5/user/viewprofilepage/user-id/5531175)

I assume this is related to your post here:

<https://community.atlassian.com/t5/Jira-questions/Create-an-automation-for-Due-date/qaq-p/2738831>

...where I recommended you look at this post.

You don't actually have to create a variable.

In your original post please show the entire automation rule you have constructed so far, and we can offer you advice specific to your situation.


author: DELACRUZ Guerdly _Gigi_
body: posted it in my original post

<https://community.atlassian.com/t5/Jira-questions/Create-an-automation-for-Due-date/qaq-p/2738831>


Tags: cloud

jira-cloud