Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,557,903
Community Members
 
Community Events
184
Community Groups

Advanced Automation: date comparison with now.StartOfMonth behaves unexpectedly

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.

1 answer

1 accepted

1 vote
Answer accepted
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Mar 20, 2023

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:

  • using the date diff function and checking the result is what you expect (positive or negative)
  • using the date formatting features to force comparable values, such as with {{now.startOfMonth.jiraDate}} and {{issue.customDateField.jiraDate}}

Kind regards,
Bill

Of course - date formatting!

Thanks, the .jiraDate seems to have done the trick!

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events