Forums

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

How to filter a query between a date range

Kevin Berrio
Contributor
February 15, 2019

I have this query:

 

project = SD AND issuetype in standardIssueTypes() 
AND status in (Closed, "SD: Resolved") AND assignee
in (currentUser()) order by created DESC

 

How can I add some JQL so that it will tell me how many tickets are done in a week?

 

Thanks again

 

 

 

1 answer

1 accepted

2 votes
Answer accepted
Ben Poulson
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 15, 2019

Is this for a specific week (like February 1-8), or for a week relative to when the query is being run (like 2 weeks ago)?

Kevin Berrio
Contributor
February 15, 2019

Relative week. I essentially want to be able to run this any week to get info on my previous week in a calendar year.

Like Marty likes this
Ben Poulson
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 15, 2019

Add this to your query:

 

resolutiondate >= startOfWeek(-1) and resolutiondate <= endOfWeek(-1)

 This will pull tickets that were resolved last week (if you want to see tickets created last week, just replace resolutiondate with createdDate). Note that jira defines a week as Sunday-Sunday, so if you run it today, it will pull anything resolved between 12:01 AM on Sunday the 3rd and 11:59 PM on Sunday the 9th. If you want it to be relative to the day of the week the query is run on, replace startofweek(-1) with startofday(-12) and endofweek(-1) with endofday(-6).

Like # people like this
Kevin Berrio
Contributor
February 15, 2019

Thank you so much for this info!

I'm still fairly new to the JQL scene, so, where would I add that to my query?

Ben Poulson
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 15, 2019

It doesn't really matter, as long as it's before ORDER BY (there's probably a best practice in terms of performance, but I honestly don't know enough about jql to tell you what it would be, but it shouldn't matter unless you are pulling 10s or 100s of thousands of issues). I generally tend to put the dates at the end of the query and in parenthesis for readability, but that's personal preference.

Example:

project = SD AND issuetype in standardIssueTypes() 
AND status in (Closed, "SD: Resolved") AND assignee
in (currentUser()) AND (resolutiondate >= startOfWeek(-1) AND resolutiondate <= endOfWeek(-1)) order by created DESC
Like # people like this
Kevin Berrio
Contributor
February 15, 2019

Wonderful,

Thanks again Ben!

This helped a lot.

Like # people like this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events