We have a custom date field that shouldn't be earlier than the first of the current month under some conditions.
Ex: This is March, so it shouldn't be set any earlier than March 1. Anytime in March or later is fine.
I have an automation set up already that works most of the time, but the behavior for a certain case is unexpected.
Automation structure: WHEN (specific field) changes AND (specific field) now = (result) AND (date comparison = true) THEN add a comment to the issue printing those dates.
The date comparison is this, using the "Advanced Compare condition"
{{issue.Custom Date}}
is less than
{{now.startOfMonth}}
Testing examples for custom date produces the following:
Testing it just now (March 20) with a Custom Date = March 23, my comment printed out as "Custom Date field cannot be any earlier than the first day of this month when [internal conditions] (March 1, 2023). The field is currently set to March 23, 2023."
Obviously the comment doesn't make sense (March 23 isn't earlier than March 1), but I'm not sure what the nuance is with now.startOfMonth that it would behave like this.
Documentation:
https://confluence.atlassian.com/automation/jira-smart-values-date-and-time-993924864.html
https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/
Thoughts?
Summary: Checking if a custom date is less than now.startOfMonth works as expected unless the custom date is between now and the end of this month.
Hi @Casey Gould
Is your custom field a date field or a date/time field?
If it is a date field, what I suspect is happening is the values are not comparing as you expect because one (or both) are converting to text for comparison). You could force the behavior you want by either:
Kind regards,
Bill
Of course - date formatting!
Thanks, the .jiraDate seems to have done the trick!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Just want to pop in and thank you @Bill Sheboy , appending .jiraDate to the end of my smart values is what made my automation rule comparing 2 different date fields work correctly this morning after a very confusing and frustrating afternoon yesterday!
Cheers
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.