Date/Time Smart Values Query

Collin Willis
Contributor
October 7, 2024

Good afternoon all, I hope someone can help me with this.

If I trigger an automation say on Tuesday at 9:00 AM. I can get the date and time for the next business day at the same time (Wednesday 9:00 AM) using {{now.plusBusinessDays(1)}}, but how do I get the next business day plus x hours (Say, Wednesday 10:00AM)?

I tried using  a fractional index on the now.plusBusinessDays like {{now.plusBusinessDays(1.25)}} to get Wednesday 15:00 (i.e. a day and a quarter (6 hours) ahead), that doesn't work.

Thanks in advance for any tips.

4 answers

Suggest an answer

Log in or Sign up to answer
1 vote
Matt Budnyj October 7, 2024

Hi @Collin Willis , to add business days and hours in an Atlassian automation, you can't use fractions like {{now.plusBusinessDays(1.25)}} to get a combination of business days and hours. Instead, you'll need to manipulate the date and time separately by adding business days and then adjusting the hours after that.

Here's how you can achieve the desired result in Atlassian Automation:

  1. Add the business days: Use {{now.plusBusinessDays(1)}} to get to the next business day.
  2. Add hours separately: Use {{now.plusBusinessDays(1).plusHours(1)}} to add extra hours to the business day.
0 votes
Aaron Morris
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.
October 10, 2024

This is an alternative solution that hard codes the time component rather than basing it on the trigger time:

{{now.plusBusinessDays(1).withHour(10).withMinute(0).withSecond(0).withMillis(0)}} 

 

0 votes
Syed Abdul Basit
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 7, 2024

Hi @Collin Willis 

To achieve the next business day plus a certain number of hours in your automation, you can't use fractional indices with now.plusBusinessDays(), as it only accepts whole day values. Instead, you need to combine now.plusBusinessDays() with a time adjustment using now.plusHours() after calculating the business day.

Here’s an approach you can use:

  1. First, calculate the next business day using now.plusBusinessDays(1).
  2. Then, add the desired number of hours using now.plusHours().

For example, if you want to get the next business day (Wednesday 9:00 AM) and add 1 hour (to get Wednesday 10:00 AM), your formula would look like this:

{{now.plusBusinessDays(1).plusHours(1)}}

This will give you Wednesday at 10:00 AM when triggered on Tuesday at 9:00 AM.

Let me know if you need further clarification or help with more complex time adjustments!

0 votes
Collin Willis
Contributor
October 7, 2024

Hi,

Sorry I reached out too soon. The answer is to use the .plusHours() method.

{{now.plusBusinessDays(1).plusHours(1)}} to return Wednesday 10:00 AM for an automation that launched on a 9:00 trigger on Tuesday.

 

TAGS
AUG Leaders

Atlassian Community Events