Trying to do a sum of two values I have
The first one is start date and the second is remaining days
Both are written in Jira description custom field
However seems that they are string and cannot be added together
I ve tried to convert them to numbers but could not
So what i am looking for is to do the addition of the date and the number of days to get the expiry date and add it to the summary
Hi @Mohamed Eid
Based on the rule images you are showing, you appear to be using Jira Server or Jira Data Center and not Jira Cloud. You may confirm that by asking your Jira Site Admin or looking at your URL: if it ends with .atlassian.net or .atlassian.com you are on Jira Cloud. Otherwise you are on Server or Data Center.
One of your Created Variables, named startdate, could be colliding with issue fields. I recommend always adding a prefix to variable names to avoid such problems, such as varStartDate.
Finally, once you confirm your Jira version, there are known problems incrementing a date / time field with a Created Variable value for Jira Data Center...even when converting text to a number. I believe the only way to solve that matches the earlier suggestion from @Tuncay Senturk to store the value in a number field (either by extraction or from the source) and then use that number field to increment the date value.
If none of those suggestions help, please work with your Jira Site Admin to contact the Atlassian Support team for assistance: https://support.atlassian.com/contact/#/
Kind regards,
Bill
Hi @Mohamed Eid
Could you elaborate further on the problem you wish to solve? You have both the start date and the remaining days in the issue's description field, and you want to perform a calculation to determine the expiry date; is that correct?
The description field is a text field and can contain a lot of free-format text, which makes implementing such a scenario unreasonable. I would strongly suggest using a separate field for each and conducting the calculation accordingly.
If I am missing anything, could you provide some examples?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So in Jira task description there is the two values as follows :
-----Q-------
Jira description :
The server xxxxx certificate is expiring in 44.9999 days,
This started at 2025-01-18 01:00:10 CET, – or 0h 0m ago.
----Unq-----
So what I want is to add 2025-01-18 01 and 44.9999 to give me the certificate expiration date which should be 2025-03-03
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I don't believe this is the most effective way to achieve this. I mean, you need to use a regular expression to parse the entire description field, select the relevant parts, and perform the calculations. This is not particularly difficult, but it is quite error-prone. There may be other dates and time indicators; how will they be handled? Additionally, there may be weeks, hours, etc.
As I mentioned earlier, it is best to use separate fields and the appropriate field types (date, number).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I suppose it should be simple and very reasonable
We have two pieces of info in each ticket description coming with the same format as provided the start date as YYYY-MM-DD and the remaining days until expiry
summing them gives the expiration date which we need to add to the summary
so no other dates or times its only one start date and one remaining days per ticket which gives us one expiration date that will be added to the summary which I could achieve
I could add the expiration date in the summary also i could extract both the start date and remaining days from the description and put them in smart variables but the addition/calculation does not work
could you please elaborate more or give an example to follow for the separation field you mentioned ? btw I am using jira automation rule for this
thank you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
so using this in a log action can extract both the start date and remaining days as follows :
Log action: Start Date: {{issue.description.substringAfter("This started at ").substringBefore(" ")}} Remaining Days: {{issue.description.substringAfter("is expiring in ").substringBefore(" days")}}
logging the output as :
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Look at this link that gives you details about how to add date and number
Examples of using smart values with dates | Cloud automation Cloud | Atlassian Support
Try this out and see if it works for you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can create two smart variables and stored the values that you have parsed. Let's say
1. CertificateIssueDate = {{issue.description.substringAfter("This started at ").substringBefore(" ")}}
2. CertificateExpiringInDays = {{issue.description.substringAfter("is expiring in ").substringBefore(" days")}}
Now create 3rd smart variable say CertificateExpirationDate and calculate the Smart value like this
{{#debug}} {{ CertificateIssueDate.toDate("yyyy-MM-dd").plusDays(CertificateExpiringInDays.asNumber)}} {{/}}
Note: For your use case I get the value as 2025-03-03
Let me know if this helps you make progress.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Vishal Biyani unfortunately it didnt work
I did the following
created variable and called it startdate with the value as below :
{{issue.description.substringAfter("This started at ").substringBefore(" ")}}
then a second variable called remainingdays with the below value :
{{issue.description.substringAfter("is expiring in ").substringBefore(" days")}}
then a 3rd variable named expirationdate as :
{{#debug}} {{ startdate("yyyy-MM-dd").plusDays(remainingdays.asNumber)}} {{/}}
and then used action log with this :
{{#debug}} {{ startdate("yyyy-MM-dd").plusDays(remainingdays.asNumber)}} {{/}}
and it gave me this
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
.toDate is missing
try with this corrected statement:
{{#debug}} {{ startdate.toDate("yyyy-MM-dd").plusDays(remainingdays.asNumber)}} {{/}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
empty again
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Share the screen shot of your automation and of the audit log by expanding each action.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
can you add debug message for each step where you are creating the smart variable?
share the audit log message in one screen shot
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Formula looks correct.
Could you add {{#debug}} {{/}} when you are creating the variables?
Let's see with that additional check to isolate where the problems could be
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
now add one more log statement like below
startdate with format = {{ startdate.toDate("yyyy-MM-dd") }} and remaining days = {{ remainingdays.asNumber }}
This should log the startdate like 2025-01-18T00:00:00.0+0000 and remaining days should print like 44.9999 correctly.
Let's see if the issue is happening in this step.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Were u able to check?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Looks like the Regex expression for remaining days is not working. Can you check if this is having any extra spaces or something like that?
if remaining days gets populated i think the rule will work.
To test the theory, you can try hardcoding the value of remaining days and see that you are getting the final output. This is to ensure there is no other issue with the rule other than populating of remaining days
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If I hardcode ramaining days to be 10 it shows it
also if in the plusdays formula i remove remainingdays.asnumber and hardcode it to a difect number like 10 it also works
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If I hardcode ramaining days to be 10 it shows it
also if in the plusdays formula i remove remainingdays.asnumber and hardcode it to a difect number like 10 it also works
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
print remaining days enclosed in pipes
{{ #debug }} |{{ remainingdays }}| {{/}}
if there is any extra character like space, we will know by seeing a gap between the digit and |.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
please make sure the syntax is correct so I can test it
{{ #debug }} |{{ remainingdays }}| {{/}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Vishal Biyani I removed the spaces and it accepted it as below :
{{#debug}}|{{remainingdays}}|{{/}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the details. This is great progress you have made.
The issue is at least isolated.
Let me think through more what else could be the issue and will respond back tomorrow morning
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you try below steps?
Fingers crossed, either of 1 or 2 should work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks a lot for your help so far @Vishal Biyani
I have tried both 1 & 2 and unfortunately they didnt work as below :
"version": "1001.0.0-SNAPSHOT", "versionNumbers": [1001, 0, 0], "deploymentType": "Cloud", "buildNumber": 100281, "buildDate": "2025-02-12T15:10:38.000+0100", "scmInfo": "f9a92c958576393f68d02ead86923e3d1fcf3671", "serverTitle": "Jira",
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Your 3rd response confirms you are on Cloud.
Since we have debugged and confirmed that asNumber is not working in your instance, in my opinion you should raise a case with Atlassian and seek their opinion.
if you have paid subscription then your JIRA admin can raise the case.
if you are on free tier, we may have to seek help of a community leader to raise the case on your behalf.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.