JQL to exclude o filter incidents created during non-working hours and weekends

Rokas May 21, 2024

Hello Jira Experts,

 

I am have some issues in Jira reports, I am trying to filter incidents created during non-working hours (from 18:00 to 22:00), excluding weekends. 
JQL should be:issuetype = Incident AND created >= startOfDay() ORcreated <= startOfDay() + 22h OR NOT (created >= startOfWeek() + 1d or created <= startOfWeek() + 2d)

But it doesn't work.... Maybe someone knows where is the issue?

1 answer

1 accepted

0 votes
Answer accepted
Dimitris Sylligardakis
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.
May 21, 2024

Hi @Rokas ,

So, unfortunately, JQL doesn't natively support time-based filtering or complex logical operations like excluding weekends directly. However, we can approximate this by breaking down your query and using available JQL functions.

Here's a way we can approach this (hope it helps you):

Filter by Working Hours (18:00 to 22:00):

    • Jira does not support direct time filtering in JQL. You'll need to use a workaround by filtering issues created within a range of days and then manually excluding weekends.

Exclude Weekends:

    • Use the startOfWeek() and endOfWeek() functions to filter out weekends.

Here's an example JQL query that might help you get closer to your goal:

issuetype = Incident AND (

    (

        created >= startOfDay("+18h") AND created <= startOfDay("+22h")

    ) AND (

        created >= startOfWeek("+1d") AND created <= startOfWeek("+5d")

    )

 

What the above does:

  • created >= startOfDay("+18h") AND created <= startOfDay("+22h"): This part filters issues created between 18:00 and 22:00.
  • created >= startOfWeek("+1d") AND created <= startOfWeek("+5d"): This part filters issues created from Monday to Friday.

This query will include incidents created between 18:00 and 22:00 on weekdays.

Limitations:

  • This query assumes the current week. If you need a more dynamic range (e.g., last week, last month), you'll need to adjust the date functions accordingly.
  • JQL does not support exact time filtering or complex logical operations, so this is an approximation.

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