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

Using plusBusinessHours does not work as expecte

Brian Pelton August 4, 2021

Trying to add hours to a custom date/time field and it doesn't update as expected. I suspect it is some kind of timezone issue? I'm using Jira Cloud.

 

Example 1 - worked as expected

Formula: {{now.plusBusinessHours(1)}}

I triggered automation on Aug 4 at 8:16 am PDT and after the automation runs the custom date/time was set to "Aug 04, 2021, 9:16 AM"

 

Example 2 - not working

Formula: {{now.plusBusinessHours(4)}}

I triggered automation on Aug 4 at 8:18 am PDT and after the automation runs the custom date/time was set to "Aug 05, 2021, 3:18 AM"

 

I'm using info from this article: https://community.atlassian.com/t5/Automation-articles/New-automation-smart-values-in-Jira-Cloud/ba-p/1402775 

1 answer

1 accepted

0 votes
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.
August 4, 2021

Hi @Brian Pelton 

That is curious, and I suspect you are correct about time zone and the hours/day and days/week setting impacting this.  You could try to force to your time zone first and see what happens, such as this using the reporter as the "anchor" time zone.  Perhaps log both with and without the increment to see what you get.

{{now.convertToTimeZone(issue.reporter.timeZone)...

Of note, I cannot tell if you are using Cloud or Server/Data Center, and when I checked the current documentation for both, neither one shows that plusBusinessHours() function.  But they might be out of date.

What problem are you trying to solve by doing this?

Best regards,
Bill

Brian Pelton August 4, 2021

Thanks for the reply,

I'm on Jira Cloud.

I found the `plusBusinessHours` function mentioned on the blog post I linked to at the bottom of my question.

I experimented a little to force a timezone, but not the way you mention so I will try that approach to see if helps.

If I can't get it working, I suppose I will open a ticket with Atlassian Support.

----

My goal is to calculate a 'follow up' or reminder date time for the ticket. Something like 'add 4 hours' each time a ticket gets a new comment. It would be nice to advance the reminder to the next business day if say the last comment is at 4pm.

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.
August 4, 2021

After a re-read of that article (emphasis is mine below), please note this function targets Jira Service Desk:

You can now play around with timestamp fields by adjusting fields at hour level. For that, you have two new functions in your pocket: plusBusinessHours and minusBusinessHours. We wanted to take business hours window dynamically from Jira Service Desk, but for now, we assume business hours are 9 AM to 6 PM, Monday to Friday.

And with some experimentation... try to log this smart value, from 0 to 10 hours of incrementing:

now+0 hours: {{now.plusBusinessHours(0).fullDateTime}} 
and diff of 0 business hour(s): {{now.diff(now.plusBusinessHours(0)).minutes}}

What I see in the log seems to indicate this starts at the next business day's start of hours (9 am) for a 0-hour increment, and continues, wrapping to the subsequent days.

audit log.png

I am unclear of the purpose of this function as it is also not listed on the Jira Service Desk (Management) smart value help.

https://support.atlassian.com/jira-service-management-cloud/docs/smart-values-date-and-time-functions/

 

Definitely time for customer service to chime in on this one.

Brian Pelton August 10, 2021

After working with support and a bit of trial and error, I ended up with:

 

{{now.convertToTimeZone(reporter.timeZone).plusBusinessHours(2)}}

Its too bad you can't pass variables as parameters, I wanted to store the number of business hours (2 in this case) as a variable and pass it to "plusBusinessHours" to simplify the automation. 

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.
August 11, 2021

Thanks, and I agree.  I submitted a defect for not being able to pass variables as function parameters last year.  Here are the public backlog items if you want to watch them:

Best regards,
Bill

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events