Forums

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

JQL is not considering the last update date of Jira

Manika Midha October 1, 2024

Hello, My query is not considering the last update date of an issue. Where am I going wrong ? Please read below for my code : 

def get_first_last_date(year, month):
_, num_days = calendar.monthrange(year, month)
first_date = datetime.date(year, month, 1)
last_date = datetime.date(year, month, num_days)


start_date, end_date = first_date.strftime("%Y-%m-%d"), last_date.strftime("%Y-%m-%d")
return start_date, end_date


def func2(year, month):
start_date, end_date = get_first_last_date(year, month)
print(start_date, end_date)

issues = jira.search_issues(jql_str=f'project = pat and status = Done and type != Bug and '
f'updated >= {start_date} and updated <= {end_date} ORDER BY updated DESC',
fields="key, reporter, assignee, customfield_10400, customfield_15041"
)

for issue in issues:
print(f"Key: {issue.key}")
print(f"Reporter: {issue.fields.reporter}")
print(f"Developer/ Assignee is {issue.fields.assignee}")
print(f"QA: {issue.fields.customfield_10400}")
print(f"Team Lead: {issue.fields.customfield_15041}")
print(issue.fields.updated)
print("\n\n")



# get jiras which were updated in the month of September 2024

func2(year=2024, month=9)

 

start_date, end_date = 2024-09-01, 2024-09-30 # in this case 

Example of issue

issue.fields.updated - 

2024-09-30T17:51:03.458-0400

1 answer

0 votes
Trudy Claspill
Community Champion
October 1, 2024

Hello @Manika Midha 

Welcome to the Atlassian community.

I suspect that the problem is related to the extra "f" and quotes you have immediately preceding updated >= in your string. Try removing those.

jql_str=f'project = pat and status = Done and type != Bug and updated >= {start_date} and updated <= {end_date} ORDER BY updated DESC'

 

Manika Midha October 1, 2024

@Trudy Claspill , I want to pass variables - start_date and end_date in the query. How else, can I write this query, please ? 

Manika Midha October 1, 2024

Just to add, even hardcoding the values instead of variables gets me the same result as using f string. Last Date is not included.

Trudy Claspill
Community Champion
October 1, 2024

As I said, I think at least part of the problem is the inclusion of the extraneous 'f' in the middle of the string. You only need the f' at the beginning of the string. Anything within curly braces between that and the closing ' will be considered a variable. 

Additionally, when using dates in a JQL the dates need to be surrounded by quotes. Try this:

jql_str=f'project = pat and status = Done and type != Bug and updated >= "{start_date}" and updated <= "{end_date}" ORDER BY updated DESC'

Lastly, I recommend that you use a print statement to print out the string you are using for your JQL so that you can confirm the variables are being substituted correctly.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events