Automation: Rule should be failing, but automation performing action anyway
Asked by Louise Baker:

Hi there!  
I need some help with automation involving comparing dates.

The end goal: if a comment is added to the ticket, compare the custom field "Last Commented Date". If the date is NOT 'today', then update the field. If it IS today, leave as is.

Attached is the rule details, plus the audit log of the most recent.

The last step in my rule is to log the date formats I'm using in the if rule, so I can confirm the date formats match.

In the attached audit log, you can see the date formats DO match, so the rule should NOT be updating the ticket, yet it is.

The "Then, Edit issue fields" is to update the custom field with {{now}} (so it includes timestamp). Could this be the issue? It doesn't seem so, since the log is showing that these two timestamps DO match.

I'm puzzled. Any advice??![lastcomment-audit.png](https://community.atlassian.com/t5/image/serverpage/image-id/345296i4516A60CA6E04578/image-size/large?v=v2&px=999 "lastcomment-audit.png")![lastcomment-details.png](https://community.atlassian.com/t5/image/serverpage/image-id/345297i8B29CCDFD49E8F86/image-size/large?v=v2&px=999 "lastcomment-details.png")


Answers:
author: Louise Baker
body: I "solved" my issue by going another route  

{{issue.customfield_10305.diff(now).days}} \> 0  

Now, if the last recorded comment date was NOT today, based on days, then it gets updated.  

I'm still not certain why the previous date comparison was not working.  
2024-09-03 != 2024-09-03 seems pretty straightforward, but it was still logging action despite them matching


author: Bharat Kalia
body: Hello [@Louise Baker](/t5/user/viewprofilepage/user-id/4751632) - I think you just have to fix the comparison in the if statement. Try using - {{Issue.customfield_10305}} does not equal to {{now.jiraDate}}.

This should fix the problem. Let me know how it goes.

Thanks,

comments: author: Marc - Devoteam
body: No, as the CF is a date time field.

The comparison should be on the date of today as a whole


author: Marc - Devoteam
body: Hi [@Louise Baker](/t5/user/viewprofilepage/user-id/4751632)

I suspect the custom field is a date field, but now is date/time.

See smart values in jira documentation -\> <https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/>

Also check this earlier community article; [Advanced-Automation-date-comparison-with-now-StartOfMonth](https://community.atlassian.com/t5/Jira-questions/Advanced-Automation-date-comparison-with-now-StartOfMonth/qaq-p/2305020)

comments: author: Louise Baker
body: The custom field is a date/time (it reports the format of Sep 3, 2024, 11:35 PM)  

However, shouldn't the conversion to .jiraDate for both now and the custom field put them on equal footing?


author: Marc - Devoteam
body: Hi [@Louise Baker](/t5/user/viewprofilepage/user-id/4751632)

That is correct, but both so todays date, after the edit action.

What do you get as log information of you would log the value of the CF before the if statement, what does the audit log then present?


author: Louise Baker
body: Ahh good point!  
I moved it to ahead of the IF, and tested a few times, and the log returns the same date formats but the action still logs.


Tags: cloud

jira-cloud