Help converting variable to date
Asked by Roger Mcgregor:

Hello, I am trying to convert in jira automation, a variable into a date. The variable is caught from the issue description field, where a due date is set as plain text. Next I try to manipulate the date with syntax:

{{Variable.toDate.plusDays(14).format("dd.MM.yyyy")}}

When I try to print out the result, it returns as empty. Log only returns the syntax with any explanation.

The idea is to compare the date from the description (variable) with and if else statement, with todays date.


Answers:
author: Bill Sheboy
body: Hi [@Roger Mcgregor](/t5/user/viewprofilepage/user-id/4725910)

For a question like this, please post an image of your complete automation rule, images of any relevant actions / conditions / branches, an image of the audit log details showing the rule execution, and explain what is not working as expected. Those will provide context for the community to offer ideas. Thanks!

Until we see those...

From what you describe and the smart value expression shown, it is likely the variable is not evaluating to a date correctly. Please try writing the variable to the audit log to confirm that.

When actions in rules have conversions like toDate that do not work, they collapse to null and "fail" silently with no error in the log.

Kind regards,  
Bill

comments: author: Roger Mcgregor
body: Sure here's screenshots of the workflow. And the summary field on issure is set to "start 17.10.2024 end".

![1.png](https://community.atlassian.com/t5/image/serverpage/image-id/336679i727FD2A1E4297AE0/image-size/large?v=v2&px=999 "1.png")![2.png](https://community.atlassian.com/t5/image/serverpage/image-id/336680i2F88FE4923ABDC91/image-size/large?v=v2&px=999 "2.png")![3.png](https://community.atlassian.com/t5/image/serverpage/image-id/336682i67690FB1B02E4D6B/image-size/large?v=v2&px=999 "3.png")![4.png](https://community.atlassian.com/t5/image/serverpage/image-id/336678iFF56BCDEBF7B16AA/image-size/large?v=v2&px=999 "4.png")

My goal is to create a scheduler that compares dates daily, and does magic if the if else statement is met or not


author: Bill Sheboy
body: This confirms the initial parsing to get the date in the variable is incorrect.

Please show an example of, and write to the audit log, the Summary for the trigger issue as that will help confirm how to adjust the parsing. That will also help when the rule fails in the future as...

**This is a risky rule / solution approach**. Putting a date value in the summary in a way that could be interpreted as either dd-MM-yyyy versus MM-dd-yyyy by a person may cause entry or understanding errors. Is this date entered by a person or created with some automated source?

Next, there is an error in your condition as it tries using *jiraDate* as a value rather than *now* . [jiraDate is a format](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/#Date-format---). (Please see below.)

Finally, to avoid the risk of a typo / error in the date comparisons, I recommend using jiraDate rather than the format() command. For example

* smart value condition
  * first value: {{DateVariable.toDate("dd-MM-yyyy").jiraDate}}
  * condition: is greater than
  * second value: {{now.plusDays(14).jiraDate}}


author: Roger Mcgregor
body: Hello,

Here's more screenshots. from summary, modified dates and log.

![1-1.png](https://community.atlassian.com/t5/image/serverpage/image-id/337872i8C25F9E00A69EFCC/image-size/large?v=v2&px=999 "1-1.png") \<--Summary

![2-2.png](https://community.atlassian.com/t5/image/serverpage/image-id/337874i740EDA913B173215/image-size/large?v=v2&px=999 "2-2.png")![3-3.png](https://community.atlassian.com/t5/image/serverpage/image-id/337875i19E836EB7A03CF05/image-size/large?v=v2&px=999 "3-3.png")

The dates come from an automated message.


author: Bill Sheboy
body: Would you please post your current, updated rule in a single image? Posting in a single image will confirm the step order / context.

If the rule is too large for one browser page, you could use a scrolling page browser addon or app to capture the image.


Tags: automation

cloud

dates

jira-cloud