Is this the proper syntax to calculate the number of months between two dates?
{{issue.Budget Coverage Period (Start date).diff(issue.Budget Coverage Period (End date)).months.abs}}
Thank you,
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...
The syntax you show appears correct. To confirm, are those both date (or date / time) fields, and are those the correct smart values for the fields?
Smart values are name, spacing, and case-sensitive...and they often do not exactly match the display names of the fields on the issue pages. When an incorrect smart value is used, it is replaced with null and often fails with no errors.
To confirm you have the correct smart values (or custom field ids) for your fields, please use this how-to article:
https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/
Kind regards,
Bill
Adding to this...
@Madar_ Andrew Have you tried to use what you've shown? Did you get an error or an unexpected result?
I wonder if the parentheses within the field names might be causing problems?
Perhaps if those were replaced with the custom field ID instead, then the rule would work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Budget Coverage Period (Start date)=2024-06-01
Budget Coverage Period (End date)=2024-12-31
{{issue.Budget Coverage Period (Start date).diff(issue.Budget Coverage Period (End date)).months.abs}}
The value returned is 6.
It should be 7. I have to perform a plus 1.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The difference appears to be a mathematical difference (i.e., 12 - 6) and not an inclusive one, counting the end points.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Any idea how to obtain the number of months which should be 7?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Will your dates always be the start / end of months? If so, add one day to the end date before performing the math.
{{issue.Budget Coverage Period (Start date).diff(issue.Budget Coverage Period (End date).plusDays(1)).months.abs}}
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.