Hi - I need to search for issues created in the last month for a report dashboard, however the business rules of the company for reporting purposes is that their month ends on the last Friday of every normal calender month. I had been using
createdDate > startOfMonth(-1) and createdDate < endOfMonth(-1)
but it is naturally starting on the 1st and ending on either the 30th or 31st, as you would expect, so this is close, but not actually doing exactly what i need.
To give a specific example of what I need, in April of 2016, I want to filter for anything in the previous month. So based on the business rule that Friday is the last day, I want the filtered range to end Friday 25th March, but the tricky part is the start of the range is actually 27 Feb.
I need the filter to be reusable, so obviously cant hard code and dates etc. Any ideas as to how I could search for my custom period?
I don't think you can do this without a custom JQL function. Normally I would be suggesting writing your own with ScriptRunner, but there is a small bug that prevents using relational operators with custom functions. I've fixed it, but won't be released for a couple of weeks.
If you want to write your own see https://developer.atlassian.com/jiradev/jira-platform/building-jira-add-ons/jira-plugins2-overview/jira-plugin-module-types/jql-function-plugin-module, the important stuff for getting the last Friday of every month is in the getValues method. Code is at https://gist.github.com/jechlin/25557469af8b8013f62c6e4d3852be27.
So to get stuff resolved in the previous month you would use:
resolutiondate > endOfBusinessMonth(-2) and resolutionDate <= endOfBusinessMonth(-1)
Thanks very much Jamie, I'll save this in my script root and will wait for the SR update you mentioned to trial it...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.