Forums

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

startOfYear / endOfYear Wrapping?

morrist1 January 23, 2019

Hi. I'm trying to setup a JQL query to setup 3 queries. One to get all issues created this January, one for January of last year, and one for January of 2 years ago.

The first one works:
project = "SomeProj" AND createdDate >= startOfYear("-0m") AND createdDate < endOfYear("-11m") ORDER BY createdDate ASC          

I assumed I could just extend the month offsets like so to get 1 and 2 years back:
project = "SomeProj" AND createdDate >= startOfYear("-12m") AND createdDate < endOfYear("-23m") ORDER BY createdDate ASC          

project = "SomeProj" AND createdDate >= startOfYear("-24m") AND createdDate < endOfYear("-35m") ORDER BY createdDate ASC          

 

However, when I do this, it always seems to give me results for January of this year. It's like, if you go beyond 12 months, it "wraps" / doesn't inc/dec the year.

Anyone know if I'm missing something here or is this just the behavior of the functions? If it is the behavior, anyone have a clever solution for writing "dynamic" queries that are valid for a specified month of the trailing n years?

Thanks in advance.

3 answers

3 accepted

1 vote
Answer accepted
Alexey Matveev
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.
January 23, 2019

Hello,

m means minutes not months. It is not possible to use months.

Mario Carabelli
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.
January 23, 2019

Hi @Alexey Matveev,

While you are right about that m is used to query minutes, you can use +-M to query for months.

You can see this in the documentation of the function:

https://confluence.atlassian.com/jirasoftwarecloud/advanced-searching-functions-reference-764478342.html

I hope you don't mind me pointing this out.

With kind regards

Mario

Like Luki likes this
Alexey Matveev
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.
January 23, 2019

Thank you for mentioning!

Like Mario Carabelli likes this
0 votes
Answer accepted
morrist1 January 23, 2019

Epic user fail. m = minutes, M = months. Sorry for wasting the KBs of disk space :)

0 votes
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.
January 23, 2019

Alexey is correct that lowercase 'm' denotes minutes, but it IS possible to denote months, by using uppercase 'M'.

Also note that you can use dates if you find that easier, e.g.

created >= '2018-01-01' and created < '2018-02-01'
morrist1 January 23, 2019

Yeah, that's what I was about to throw in the towel and do, then I realized m = minutes and M = months. I'd prefer to not have to rev this every year. Thanks though.

Mario Carabelli
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.
January 23, 2019

@Payne
Sealan  and  @morrist1

If you use dates be aware that they assume use as a default date time 12am. To really get all issues in the year you should go with:

Created >= '2018-01-01 00:00' AND Created <= '2019-01-01 00:00'

With kind regards

Mario

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.
January 24, 2019

Right, Mario, but they are equivalent. Omitting a time assumes 00:00 as you point out, so no need to explicitly state it. One should be aware of that in choosing the end date, though, and add one day to it, e.g. created < '2018-02-01', since created <= '2018-01-31' would not include any issues from 1/31.

Mario Carabelli
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.
January 24, 2019

@Payne

Did you test this?

12:00 as default would make sense too because it is exactly the middle of the day.

I got the information from this thread :

https://community.atlassian.com/t5/Jira-questions/Search-between-two-dates-doesn-t-seem-to-be-inclusive-and-is/qaq-p/266367

But I didn't tested it so maybe the information there is outdated or missinformed.

With kind regards

Mario

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.
January 24, 2019

Yes, I have tested and confirmed that the default time, if none is specified, is 00:00 (midnight), not 12:00 (noon).

The accepted answer on the post you reference matches my explanation.

-Payne

Suggest an answer

Log in or Sign up to answer