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:
- last month
expectation: conditional triggered, automation comments
actual: as expected - next month
expectation: condition not triggered, no comment
actual: as expected - earlier this month
expectation: condition not triggered, no comment
actual: as expected - later this month
expectation: condition not triggered, no comment
actual: comment!
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.