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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How can I query tickets which was created after past Thursday? Edited

Our oncall week starts from Thursday to next Wednesday.

I want to build a filter for search all tickets that crated during these 7 days. 

The oncall week is across 2 weeks. startOfWeek may not work as expected.

project = "Oncall" AND created >= startOfWeek(4d)

This will work in Thursday, Friday Saturday of the week-1, but it may not work for Sunday, Monday, Tuesday, Wednesday of the week-2.

                      On-call week
+-----------------------+
| |
SUN MON TUE WED THU FRI SAT SUN MON TUE WED THU FRI SAT
| | | |
+---+---+ +-----+-----+
| | in these days we need to use:
| +-----> created >= startOfWeek(-3d)
|
| in these days we need to use:
+--> created >= startOfWeek(4d)

 

How can I combine them to one single JQL, something like this

(created >= startOfWeek( 4d) AND now().dayOfWeek() in (THU, FRI, SAT)) OR (created >= startOfWeek(-3d) AND now().dayOfWeek() NOT IN (THU, FRI, SAT))

But now().dayOfWeek() doesn't work in JQL.

2 answers

1 accepted

0 votes
Answer accepted

I finally cracked it.

My actually use case is that the oncall started from Tuesday. (I used Thursday as start day in the question for easy to describe).

created >= startOfWeek(2d)

This will work well, when the time is in first week(Tuesday ~ Saturday).

But it will select nothing when the time enters the 2nd week(Sunday and Monday) because `startOfWeek(2d)` means current week's Tuesday which is in the future.

Suppose it is Sunday now. (Apparently it is 2nd week's Sunday), how can I match the JIRA of last Tuesday, Wednesday, Thursday, Friday and Saturday?

(created >= startOfWeek(-5d) and created < startOfWeek(-4d) 

matches last Tuesday. 

created >= startOfDay(-5d) and created < startOfDay(-4d))

matches the day before 5 days 

So the following criteria would match (the last Tuesday which is before 5 days)

(created >= startOfWeek(-5d) and created < startOfWeek(-4d) and created >= startOfDay(-5d) and created < startOfDay(-4d))

Only on Sunday it could match JIRAs. It won't match anything on any other day, for the day before 5 days wouldn't be Tuesday on any other days.

By this way, we can build criteria which would only valid on Sunday:

  1. matches last Tuesday which is the day before 5 days
  2. matches last Wednesday which is the day before 4 days
  3. matches last Thursday which is the day before 3 days
  4. matches last Friday which is the day before 2 days
  5. matches last Saturday which is the day before 1 days

Also we can build criteria which would only valid on Monday:

  1. matches last Tuesday which is the day before 6 days
  2. matches last Wednesday which is the day before 5 days
  3. matches last Thursday which is the day before 4 days
  4. matches last Friday which is the day before 3 days
  5. matches last Saturday which is the day before 2 days
  6. matches this week's Sunday which is the day before 1 days

Here is my solution -

(created >= startOfWeek(2d) OR
created >= startOfDay() OR
(created >= startOfWeek(-5d) and created < startOfWeek(-4d) and created >= startOfDay(-5d) and created < startOfDay(-4d)) OR
(created >= startOfWeek(-4d) and created < startOfWeek(-3d) and created >= startOfDay(-4d) and created < startOfDay(-3d)) OR
(created >= startOfWeek(-3d) and created < startOfWeek(-2d) and created >= startOfDay(-3d) and created < startOfDay(-2d)) OR
(created >= startOfWeek(-2d) and created < startOfWeek(-1d) and created >= startOfDay(-2d) and created < startOfDay(-1d)) OR
(created >= startOfWeek(-1d) and created < startOfWeek() and created >= startOfDay(-1d) and created < startOfDay()) OR
(created >= startOfWeek(-5d) and created < startOfWeek(-4d) and created >= startOfDay(-6d) and created < startOfDay(-5d)) OR
(created >= startOfWeek(-4d) and created < startOfWeek(-3d) and created >= startOfDay(-5d) and created < startOfDay(-4d)) OR
(created >= startOfWeek(-3d) and created < startOfWeek(-2d) and created >= startOfDay(-4d) and created < startOfDay(-3d)) OR
(created >= startOfWeek(-2d) and created < startOfWeek(-1d) and created >= startOfDay(-3d) and created < startOfDay(-2d)) OR
(created >= startOfWeek(-1d) and created < startOfWeek() and created >= startOfDay(-2d) and created < startOfDay(-1d)) OR
(created >= startOfWeek() and created < startOfWeek(1d) and created >= startOfDay(-1d) and created < startOfDay()))

 

Check this:

created >= startOfDay(-6) 

project = "Oncall" AND created >= startOfWeek(-3d)

When the time is 2nd week, it works.

When the time is 1st week (Thursday, Friday, Saturday), it doesn't work.

The issue is you want to use an IF condition in your JQL but as far as I know there is no IF in JQL.

No, it is not "IF"

It need something like this:

(created >= startOfWeek( 4d) AND now().dayOfWeek() in (THU, FRI, SAT)) OR (created >= startOfWeek(-3d) AND now().dayOfWeek() NOT IN (THU, FRI, SAT))

Let me reformulate my "IF" comment :)

I think this is your requirement:

IF Today = Monday 

  issues from last week Wednesday till Today

Else IF Today = Tuesday

  issues from last week Wednesday till Today

Else IF Today = Wednesday

  issues from Today

Else IF Today = Thursday

  issues from this week Wednesday

....

So you need to know what is the day today. But from JQL you cannot get this, from JQL you can get Issues based on some criteria. 

Is that a solution to create separate filters (naming them as Monday, Tuesday, etc.) and use them as Quick Filters - selecting every day the relevant one?

 

See my answer above. I found a solution.

Like Szabolcs Kiss likes this

Nice filter, good to learn new things :) 

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you