Forums

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

search date range between specific days of unspecific months

Julia Zastrow [demicon]
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!
August 3, 2018

Hi folks,

I need some help with a search. I know that I can use startOfMonth() and endOfMonth() to search tickets in this range. But what I need is a search between the 28th of a months and the 27th of the next months. So to speak my month will start on the 28th and not on the 1st and will end on the 27th and not on the 30th.

For example:

Issues created between 28.07. and 27.08.

But I will not have to change my query every month as I will need the same query again for the 28.08. - 27.09. and so on.

 

I hope this is quite understandable.

1 answer

0 votes
Deleted user August 3, 2018

Hi @Julia Zastrow [demicon],

The best solution I can offer by just using a JQL query:

created >= startOfMonth(-34d) AND created <= endOfMonth(-35d) 

However, this will only work with months with 31 days. You could create a separate JQL query for the months with 30th days and another to take into account February however this is not an optimal solution. 

I think you may need to look into an add-on such as Script Runner

Hope this helps

Julia Zastrow [demicon]
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!
August 7, 2018

Hi Danny,

thanks for this fast reply! This query works fine for the last month but not for the current one. My problem is to find a query that is valid beyond the change of months.

Best regards

Julia

Deleted user August 7, 2018

Hi @Julia Zastrow [demicon],

I will shout out to the other Champions to see if they know of a method to achieve your requirements.

Apologies I cannot be any further assistance directly.

Tarun Sapra
Community Champion
August 7, 2018

Since the duration of month also varies (30, 31, 28 or 29 (leap year) days) thus hardcoding the days won’t always work

Scripting seems to be the possible solution

Please see here how to write an custom JQL function

https://scriptrunner.adaptavist.com/latest/jira/custom-jql-functions.html

Or a custom JQL plugin

https://developer.atlassian.com/server/jira/platform/adding-a-jql-function-to-jira/

Tarun Sapra
Community Champion
August 7, 2018

Java 8 time features (this will work in groovy as well)

https://www.baeldung.com/java-8-date-time-intro

Suggest an answer

Log in or Sign up to answer