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

Advanced date compare to get current half year

systems-intern March 8, 2022

Hello,

i need to write an automation for an internal control system that opens control tickets with different frequencies. For this purpose, it reads the stored frequency from a customfield of a control datasheet ticket. The options are daily, weekly, monthly, etc.. Now I have to open a control activity issue, which contains, depending on the frequency, the day, the week, the quarter or the information whether one is in the 1st or 2nd half of the year in the ticket summary. Unfortunately, it seems there is no easy way to get the half-year. Therefore I used if else functions, which compare {{now}} with the date 01.07 and if the date is before 01.07 1st half year is used and starting from the 01.07 the 2nd half year. Currently I use: {{now.compareTo(now.withMonth(7).withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0).withMillis(0))}}
Is there possibly an easier way here? Except to build own automations for both half year options, which run on 01.01 or 01.12.

2 answers

0 votes
Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 8, 2022

Hi @systems-intern ,

for deeper understanding and analyze please consider to also provide further information in the form of screenshots of eg. issues, current automation rule,...

From what you wrote at the end (the compare date regard 1st or 2nd half of the year):

would the following solve that in an easier fashion:

{{[date1].isBefore([date2])}}

see also:
https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/#--

or did i get something wrong?

Best
Stefan

Mark Chaimungkalanont
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 20, 2022

You can get the number of month by doing something like: 

{{now.monthOfYear}}

So you can do something like

{{#if(now.monthOfYear.gt(6))}} Second half of year {{/}}
0 votes
systems-intern March 8, 2022

correction of the last sentence: i meant 01.01 and 01.07 :)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events