Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Smart value to set Date/Time for 5pm same day

Kate
Contributor
July 3, 2023

Help with Automation Smart values please?

I have created an automation that calculates a due date/time field based on when the ticket is lodged. This smart value works perfectly:

{{issue.customfield_1003.plusBusinessDays(5)}}

The team have now asked if a certain field is selected, can the due date auto calculate to 5pm that same day (aka end of that business day). Does anyone know a smart value that would allow for this?

1 answer

1 accepted

0 votes
Answer accepted
Darryl Lee
Community Champion
July 3, 2023 edited

Hi @Kate -

It's kind of a weird syntax, but playing around with "To date with time conversion" I came up with this:

 {{now.withHour(17).withMinute(0).withSecond(0)}}

Which returned:

2023-07-04T17:00:00.0+0000

Which hrm, that's 5PM tomorrow, since it's not my time zone.

So I then added my time zone:

{{now.convertToTimeZone("America/Los_Angeles").withHour(17).withMinute(0).withSecond(0)}}

There we go:

2023-07-03T17:00:00.9-0700

So yeah, that ought to work.

Darryl Lee
Community Champion
July 3, 2023

Caveat, it's 7:54PM in my time zone, so things might get a little trickier if say, at 5:01PM, you wanted the date to be the next business day at 5PM.

You could probably do some conditional logic and use the isAfter function. Maybe in conjunction with toDateTimeAtStartOfDay.

Like • John Funk likes this
Darryl Lee
Community Champion
July 3, 2023

Why oh why doesn't Automation have an ELSE operator? I ended up having to have back-to-back IFs to get this to work:

{{#if(now.convertToTimeZone("America/Los_Angeles").isBefore(now.convertToTimeZone("America/Los_Angeles").withHour(17).withMinute(0).withSecond(0)))}}{{now.convertToTimeZone("America/Los_Angeles").withHour(17).withMinute(0).withSecond(0)}}{{/}}{{#if(now.convertToTimeZone("America/Los_Angeles").isAfter(now.convertToTimeZone("America/Los_Angeles").withHour(17).withMinute(0).withSecond(0)))}}{{now.plusDays(1).convertToTimeZone("America/Los_Angeles").withHour(17).withMinute(0).withSecond(0)}}{{/}}

Caveat: If somebody somehow sets that field at EXACTLY 17:00:00.0... I'm not sure what will happen. :-}

Like • John Funk likes this
Kate
Contributor
July 4, 2023

Thanks Darryl! I tried using this option:

{{now.withHour(17).withMinute(0).withSecond(0)}}

 and its defaulting for the next day for me as well! I'm located in NZ, so I don't think it's a timezone issue, but it's definitely a head scratcher. This is a great starting point though!

Darryl Lee
Community Champion
July 4, 2023

Hi Kate - I would try this to see if it gives you what you're expecting:

{{now.convertToTimeZone("Pacific/Auckland").withHour(17).withMinute(0).withSecond(0)}}
Like • Kate likes this
Kate
Contributor
July 4, 2023

@Darryl Lee I have no idea why that works, but it works! thank you so much!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
atlassian, confluence, loom, atlassian intelligence, ai notes, ai-powered meeting notes, atlassian community events, ace, confluence ai, loom ai integration, ai note-taking, atlassian ai features, team '25, atlassian live learning, confluence automation

Unlock AI-powered meeting notes: Join our live learning session! 📹

Did you catch the news at Team ‘25? With Loom, Confluence, Atlassian Intelligence, & even Jira 👀, you won’t have to worry about taking meeting notes again… unless you want to. Join us to explore the beta & discover a new way to boost meeting productivity.

Register today!
AUG Leaders

Atlassian Community Events