Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×I have automation rules that automatically set the start/end time to {{now}} based on ticket transitions on change tickets.
This works exactly as intended.
For reporting and tracking purposes on the change calendar, I want to modify that time when I set it to the nearest half hour. (we would still track the actual timestamps via the change history.)
I've experimented with this but keep getting syntax errors:
{{now}.withMinute({{now}.minute}.divide(30).floor.multiply(30))}
Here's my thought process on how I expected this to work:
1. {now}.minute - extracts the number of minutes from the current time
2. .divide(30) produces a fractional amount >0 and <2
3. .floor returns either 0 or 1
4. .multiply(30) returns 0 or 30
5. .withMinute() gets the above result and sets the time to the current time, with minutes set to either :00 or :30
Could it be that .minute is not returning an integer that allows me to use arithmetic functions? Or even more basic, am I not able to access that attribute directly?
Is this even possible?
@ian.silver,
I approached it in a more simple way. I just pulled the minutes value from the date/time and used that inside of an if condition to choose how the date/time issue should be set.
As you can see by my rule, anything logged within the first 15 minutes of the hours goes to the beginning over the hour. From minutes 16-44, it'll go to 30 minutes, and everything over 45 minutes will go to the start of the next hour. You'd also need to include conditions for 15 minutes and 45 minutes to make sure those go where you want as Jira doesn't include a "greater than or equal to" condition. I hope this helps!
Thanks,
Kian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Based on your response on the other answer, you'll need to tweak the logic, but it should be pretty simple to do!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I did just that. My primary objective was to ensure consistent and clear visibility of change tickets in our change calendar. When a change required only 5-10 minutes to execute, it appeared as a nearly invisible line on the calendar!
I've modified both of my automation rules for optimal results. For the change start time, I use a simplified version of your suggestion:
If the minutes are less than 31, set the time to {{now.withMinute(0)}}
Otherwise set the time to {{now.withMinute(30)}}
This makes all our changes appear to start at the top or the bottom of the hour.
For the completion time, I needed to first make one additional check to ensure that short-duration changes still appear as a minimum 30-minute change:
{{Change completion date.diff(Change start date).minutes}}<30
If true, then {{Change completion date.plusMinutes(30)}}
Otherwise use the same if/then/else as for the start time rule.
Thanks for the guidance!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm glad I could help! Have a great day!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @ian.silver
If I understand correctly, you want to round off the time to nearest half an hour in a sense if the current time is like
Is that what you are looking for?
In that case, you can use the smart values for date and time as mentioned in the article: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/ and set it accordingly in the automation rule.
If so, can you mention what the expected round-off time should be in the above scenarios?
Thanks,
Vamsi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vamsi,
Thanks for your reply. You have correctly restated my objective.
I probably should have said I was trying to round down to the nearest half-hour. (There is another complicating factor, but I think I can handle that once I get this functioning properly.)
If I could add a static value I could use
{{[date].plus[Unit]([number])}}
The challenge has been that the number of minutes to be added/subtracted to the current time depends on what time it is. I cannot simply add or subtract a fixed number of minutes.
For example, if the actual start time is 02:04 AM, I need to subtract 04 minutes, but if the start time is 02:14, I need to subtract 14 minutes.
The formula I provided in my original post was attempting to address this by turning any time between nn:00 and nn:30 to 0, and any time between nn:31 and nn:59 to 1, allowing me to then use a static value of 30 to modify the time (either 30*0, or 30*1)
If there is something in the article that you referenced that addresses this that I missed, can you please point that out to me?
Smiles,
Ian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @ian.silver
I am enclosing the screenshot here for your reference.
It is self-explanatory but still I will explain:
In the 'if' condition, I am checking if minutes are greater than 30, i.e. if the time is 2:37 PM, I am rounding it to 3:00 PM.
In the 'else' condition, I am checking if the minutes are less than 30, i.e. if the time is 2:15 PM, I am rounding it to 2:00 PM.
You can check and use the smart values I have used for your purpose.
Hope this helps.
Thanks,
Vamsi
The 'if' condition block
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As suggested by you, I am trying to set date/time picker field using following smart value. However, it shows syntax error "This smart value is invalid". Would you pls suggest if I am making any mistake here ?
{{now.jiraDate}}T{{now.hour}}:00:00
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Show up and give back by attending an Atlassian Community Event: we’ll donate $10 for every event attendee in March!
Join an Atlassian Community Event!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.