Forums

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

trying to set the date between two options to the minimum

Una Horne February 5, 2025

basically, i have a task that needs to (once autopopulated) set the due date to either tuesday or friday depending on which one is closer. i have no issues with making it populate to tuesday OR friday with {{now.withNextDayOfWeek("XXX")}}, but i know there is a function that can be used "min" to make it decide which one to assign it to. is there any solution to this? ive tried:

{{MIN(now.withNextDayOfWeek("TUE"), now.withNextDayOfWeek("FRI"))}}{{(now.withNextDayOfWeek("TUE"), now.withNextDayOfWeek("FRI"))MIN}}{{now.withNextDayOfWeek("TUE"),("FRI").min}}

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.
February 5, 2025

Hi @Una Horne 

Your syntax is not correct for using the min function...

The min function may be used with the long, format of a math expression or with a list of values (either numbers or dates / times).

 

One way to solve what you asked is to create a list of dates to use the min function:

{{now.withNextDayOfWeek("TUE").jiraDate.concat(",").concat(now.withNextDayOfWeek("FRI").jiraDate).split(",").toDate.min}}

How that works:

 

Kind regard,
Bill

Una Horne February 5, 2025

wow, this looks like it worked!! ill know for sure if i try the rule again on friday. thank you so much @Bill Sheboy ! incredible :)

Like Bill Sheboy likes this
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.
February 6, 2025

FYI, another way to do this is with a conditional expression:

{{if(now.format("E").match("(Tue|Wed|Thu)").length().gt(0), now.withNextDayOfWeek("FRI").jiraDate, now.withNextDayOfWeek("TUE").jiraDate)}}

If we know today's day-of-week is Tuesday, we know we want the next Friday.  Same thing with Wednesday and Thursday. 

All other days lead us to the next Tuesday.

 

Una Horne February 7, 2025

@Bill Sheboy i am fascinated with this, i am at the beginning of my jira experience. i have zero coding background. is there a resource you recommend for people like me where i can learn this kind of stuff? i have another thing im trying to do, and i get the feeling it is going to involve a more in-depth solution rather than my sloppy use of smart values pasted together like i tried before lol

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.
February 7, 2025
Like Una Horne likes this
Una Horne February 7, 2025

ill definitely be reading up on these, thank you so much!

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events