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
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'
@Trudy Claspill , I want to pass variables - start_date and end_date in the query. How else, can I write this query, please ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Just to add, even hardcoding the values instead of variables gets me the same result as using f string. Last Date is not included.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.