Forums

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

How to get the Difference between Dates and Update the field in Automation

Sanjivani Wayal
Contributor
July 17, 2023

HI,

field "DATE1" already has some date. 

Need to update DATE1 as (DATE1 + Variable) where variable is (todays date - DATE2)

DATE2 is another date Field 

 

Need to write this in Automation

1 answer

1 accepted

2 votes
Answer accepted
Trudy Claspill
Community Champion
July 17, 2023

Hello @Sanjivani Wayal 

You can find information about functions you can use with date and date/time fields in Automation rules on the following page:

https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time

Take a look at the information there and then let us know if you need additional help.

Sanjivani Wayal
Contributor
July 17, 2023

HI , we can use 

{{[date1].diff([date2]).[unit]}} but it is not giving the date it has below units 
millis

seconds

minutes

hours

days

weeks

months

years

businessDays

But i need difference in Dates like  if now() - 11/7/2023 it should give DATE  7/7/2023.

Trudy Claspill
Community Champion
July 18, 2023

The diff function is going to give you the amount of of the difference between two dates.

If you want to use that to create another date, you apply that difference to another date.

Your statement was:

Need to update DATE1 as (DATE1 + Variable) where variable is (todays date - DATE2)

The diff function will give you the value for Variable. You have to use the plus[Unit]([number]) function to then apply that variable to DATE1.

Sanjivani Wayal
Contributor
July 19, 2023

Hi @Trudy Claspill 

Could you please help me how can i write this in Automation declaring variable is new for me

Trudy Claspill
Community Champion
July 20, 2023

I encourage you to at least try to construct the automation and show us what you are able to put together. At least get the steps (Trigger, Conditions, Actions, etc.) in place and see if you can figure out the correct settings. Set up a test project with test issues to test the automation rule.

Here is a link to the Automation Rules documentation:

https://support.atlassian.com/cloud-automation/docs/jira-cloud-automation/

Two things that are very helpful:

1. The Audit Log - Every change and publish of the rule and every execution of the rule will create an entry in the Audit Log. You can expand the individual entries to see the details.

Screen Shot 2023-07-20 at 9.36.08 AM.png

Screen Shot 2023-07-20 at 9.37.31 AM.png

 

2. Use the Log action to print messages into your Audit Log. You can print plain text and include any smart value that you could use in your rule. I use it to print original values from fields and print out any calculations I'm trying to do, like calculating the number of days between two dates.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events