JQL query

Stanislav
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.
June 15, 2021

I want to show closed issues. But i got 2 jql query. One is for issue from start of the month till now.
For example we are in 15.06 we need this for second jql. And second jql the most hard for me to understand is issues from the past month but the same day as current month so for example today is 15.06 and i need to see from 01.05 to 15.05 of the previous month.  And it should be dynamic so the next day 16.06 i want to see previous month from 01.05 to 16.05 and so on.

1 answer

1 accepted

1 vote
Answer accepted
Payne
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.
June 15, 2021

This is tricky. You can start a JQL search with date >= startOfMonth(-1) to get the 01.05 part, but I'm not sure how you'd go about getting the 16.05 part. You can hard code dates in the JQL like created >= '2021-05-01' and created <= '2021-05-15 23:59', but I know you don't want to do that, since you'd have to change it every day.

Here's an approach I have taken in cases like this, since you can embed JQL in links - create a local basic page on your workstation with links that you can manipulate with Javascript. Here's one I threw together for your purpose. You can save this somewhere as jira.htm, for example, and load it and click it when you need it. You could put other useful links on it as well.

<html>
<head>
<title>Jira Links</title>
<body>
<a id="last_month_issues">Jira Issues - Last Month Through Current Day</a>
<script>
function generateLink(){
var today = new Date();
var thisMonth = today.getMonth(); // 0=January
var thisDay = today.getDate();
var thisYear = today.getYear(); // Number of years since 1900 (e.g. 2021 = 121)
var lastMonth,lastMonthYear;
if(thisMonth == 0)
{
lastMonth = 11;
lastMonthYear = thisYear - 1;
}
else
{
lastMonth = thisMonth - 1;
lastMonthYear = thisYear;
}
lastMonth += 1;
lastMonthYear += 1900;
var myJira = "https://YOURJIRA"
var field = "created" // whichever field you wish to check
var link = myJira + "/issues/?jql=" + field + "%20>%3D%20%27" + lastMonthYear + "-" + String(lastMonth).padStart(2,'0') + "-01%27%20and%20" + field + "%20<%3D%20%27"+String(lastMonthYear).padStart(2,'0') + "-" + String(lastMonth).padStart(2,'0') + "-" + String(thisDay).padStart(2,'0') + "%2023%3A59%27";
document.getElementById("last_month_issues").href = link;
}
generateLink();
</script>
</body>
</html>

Suggest an answer

Log in or Sign up to answer