We have a number of recurring maintenance windows every month which are specified by the week number and the day of the week (ex. second Wednesday every month). I need to be able to write a query to show me all the tickets due the second wednesday of every month and the second sunday of every month. I can sort of specify the second week of the month using startOfMonth +/- and filtering for the 8th to the 14th, but I can't see a way to get it to only show me tickets that are due on a Wednesday. It seems that startOfWeek and endOfWeek only works to specify a day of the week for the past 7 days.
Is there not a way to get a list of all tickets that are due this month on a Wednesday?
startOfWeek(3d), startOfWeek(10d), startOfWeek(17d), startOfWeek(-4d) are all Wednesdays, so something like:
duedate = startOfWeek(-25d) OR duedate = startOfWeek(-18d) OR duedate = startOfWeek(-11d) OR duedate = startOfWeek(-4d) OR duedate = startOfWeek(3d) OR duedate = startOfWeek(10d) OR duedate = startOfWeek(17d) OR duedate = startOfWeek(24d)
should identify all Wednesdays from today back to the beginning of the month as well as forward to the end of the month (plus a bit into the previous month or forward to the next month, depending upon which week you're in). If you then combine that with your idea of limiting to the 8th through the 14th utilizing startOfMonth(), something like the following may be what you need:
duedate >= startOfMonth("+7d") AND duedate <= startOfMonth("+13d") AND (duedate = startOfWeek(-25d) OR duedate = startOfWeek(-18d) OR duedate = startOfWeek(-11d) OR duedate = startOfWeek(-4d) OR duedate = startOfWeek(3d) OR duedate = startOfWeek(10d) OR duedate = startOfWeek(17d) OR duedate = startOfWeek(24d) )
That's basically what I have now, but the issue is that I can't separate out the tickets due the same week, but on different days (and therefore on different maintenance windows).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The example I provide will list only issues due on the 2nd Wednesday; you could have a second filter, a variation of this one, that would list issues due on the 2nd Sunday, your other maintenance day.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No, as soon as you hit the 1st day of a new month, the filters should then list issues for the new month, thanks to the duedate >= startOfMonth("+7d") AND duedate <= startOfMonth("+13d") portion of the JQL. The numbers in the startOfWeek() calls (-4, 3, 10, etc.) will always work, as those are offsets in relation to Sunday (day 0).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is fantastic! I've set up queries using duedate and I can get all the specific days I want! However, if I use our custom Maintenance field, which has a date and time, it looks like startOfMonth works fine, but startOfWeek does not. Grrr so close! I will keep at.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You both almost have it!
Now that you've got a method for getting issues due on Wednesdays, as well as a range of days of month where the a second weekday can occur, you just need to combine both queries in an appropriate manner:
And you got it! :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Finally, you may use your combined filter in any other queries like this:
type = Maintenance AND filter = "Due 2nd Wednesday"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Martha - Glad you're getting close! Due Date is a date field (no time component), so checking for equality (e.g. duedate = startOfWeek(3d)) works. For a datetime field, though, it needs to be expanded a bit like this: maintenance >= startOfWeek(3d) and maintenance < startofWeek(4d). So, you'll want to replace each startOfWeek() check with a pair like that. i.e.
duedate >= startOfMonth("+7d") AND duedate <= startOfMonth("+13d") AND ( (maintenance >= startOfWeek(-25d) and maintenance < startOfWeek(-24d) ) OR (maintenance >= startOfWeek(-18d) and maintenance < startOfWeek(-17d) ) OR ...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Ignacio Pulgar @Payne @Martha
Guys, Please help me with the JQL for retrieving issues created on Saturday and Sunday for each week.
Unable to retrieve those issues I have to use this filter for Dashboard to track the newly created tickets on Saturday and Sunday for every week...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@AKBAR Can you confirm, you need a query to show you all issues created on Saturday and Sunday for the previous week? If so, the query would look something like this:
(project=yourTeamName AND createdDate=startOfWeek(-6)) AND (project=yourTeamName AND createdDate=startOfWeek()) AND createdDate <=1w
startOfWeek(-6) is Saturday and startOfWeek() is Sunday. To specify only tickets created on Saturday or Sunday in the past week, you just add createdDate with a range of less than 1 week.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@MarthaThe above query isn't returning me the results.
Instead I tried as below;
" project = ABC and (Created >= Saturday Date1 and Created <= Monday Date1) OR (created >= Saturday Date2 and created <= Monday Date2) "
Saturday date1 is the Saturday of the first week and Saturday Date2 is the Saturday of the second week. and vice versa for Monday also.
I have to change the dates of Saturdays and Mondays every month...
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@AKBAR what are results do you get from the query? (The one using startOfWeek(-6) and startOfWeek().)
I should say that to show all tickets created on Saturday/Sunday for the past month, see the very first response in this thread. To cover the entire month, you need something like:
To get all Sundays in the month: CreatedDate = startOfWeek() OR createdDate = startOfWeek(7) OR createdDate = startOfWeek (21) OR createdDate = startOfWeek(28)
Then just include the same for all Saturdays, so include startOfWeek(-6), startOfWeek(6), startOfWeek(12), startOfWeek(24), startOfWeek(30)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Someone with coding skills might find inspiration by having a look at these sources:
https://github.com/adamstraube/JiraJavaGroovyScripts/blob/master/Day-of-week.groovy
Maybe a custom field set by a Script Listener listening for Issue Edited events can do the job:
https://scriptrunner.adaptavist.com/latest/jira/listeners.html
Or maybe a Scripted Field:
https://scriptrunner.adaptavist.com/latest/jira/scripted-fields.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I make script field in adaptavist scriptrunner:
import com.atlassian.core.util.DateUtils
import com.atlassian.jira.datetime.LocalDate
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.RendererManager
if (!issue.getResolutionDate()) return -1
def timestamp = issue.getResolutionDate()
def cal = Calendar.getInstance()
cal.setTime(new Date(timestamp.getTime()))
double weekday = cal.get(Calendar.DAY_OF_WEEK) - 1;
if (!weekday) return 7
return weekday
Return:
1 - Monday
2 - Tuesday
...
7 - Sunday
-1 - issue not resolved
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The Script Listener approach would require to listen to Issue Created events, as well.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the response! We've basically done the setup you suggested: we already had an issue type for Maintenance, and we've also added a Maintenance Close Window that is a specific date, so I can search for those (we still have Due Date as well). The problem is that it will take some time to update all the tickets, as well as getting people to put in the maintenance tickets correctly in the future, so I was hoping for some sort of work around in the meantime. Additionally, this setup allows me to display all the maintenance tickets for a given time frame, but I still can't display only the tickets for the next maintenance window, unless I hard-code the date (which then has to be updated every month).
However, I'm told we do have ScriptRunner, though I've never used it before. Would I be able to create a script to search for things like tickets due every second Wednesday of the month?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.