Forums

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

query to include only weekends

Erica Escobar
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 14, 2022

I am looking to create a query that pulls reports for only weekends (Saturday and Sunday) for the entire year.

Please advise if this is possible or for any alternatives.

Thank you. 

Erica Escobar

2 answers

2 votes
Johnny Mon
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 21, 2022

Hi @Erica Escobar,

This is a late response to discuss an alternate solution:

The JQL for getting the ‘past weekend issues’, for example, created in the past weekend, is

(createdDate >= startOfWeek(-1d) AND createdDate < startOfWeek(1d)) order by createdDate ASC

The startOfWeek() can be use repeatedly to get previous weeks as well. Here is an example for the past 4 weekends:

(createdDate >= startOfWeek(-1d) AND createdDate < startOfWeek(1d) )
OR (createdDate >= startOfWeek(-8d) AND createdDate < startOfWeek(-6d))
OR (createdDate >= startOfWeek(-15d) AND createdDate < startOfWeek(-13d))
OR (createdDate >= startOfWeek(-22d) AND createdDate < startOfWeek(-20d))
ORDER BY createdDate ASC

Because all the data are historical, we can utilize JQL to get the past weekend data, once a week, in a scheduled job. The data for each weekend can be inserted into a database table or concatenated into a data store, which you can use to run the reports.

To populate the previous weeks' data, we can use the example JQL above with OR clauses, or run them in separate queries, one for each weekend.

The previous comment on using a custom script field in ScriptRunner will work seamlessly with reports by adding a new custom field that marks an issue as a ‘weekend issue' and then utilizing it in a filter.

Hope the new information helps.

Natasha Richardson
Contributor
August 25, 2023

Thank you. This simplified things for me. The date functions and logic are some of the most confusing JQL queries for me.

0 votes
David Berclaz _Apwide_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 14, 2022

Hi @Erica Escobar

Welcome to the community!

What kind of query are you thinking about? A query listing all Jira issues created (or resolved?) during the weekend?

On Jira Server/DC I would be using a Script Field (ScriptRunner App), but I'm not sure how to do it on Jira Cloud.

Cheers,

David

Suggest an answer

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

Atlassian Community Events