I’m currently trying to create a query that will show all tickets from queue X that were created during the previous month that have since been resolved.
What I have tried: Queue = ‘X’ AND Created > ‘last month’ AND Created < ‘this month’ AND Status = ‘resolved’
This did not give me any results. I believe the problem to be the “last month” part, since “this month” works well in other queries.
Another tactic I tried: Queue = ‘X’ AND Created > ‘-2 months’ AND Created < ‘-1 month’
This query works, but instead giving the tickets that were created last month it gives me tickets that were created 62-31 days ago. Right now I need the tickets only from June but this query shows tickets created before that.
I think the problem here is that Time::ParseDate can either work in absolute date/times, or date/times relative to now. I’m not sure there is a way of saying “1st June-30th June” when in an arbitrary day in July, as “last” and “ago” are relative to the day you’re on in July.
Yeah, so far I’ve been manually changing the days for these searches (with multiple different custom fields) each month, because I haven’t figured out if there is a way to build a query “1st of previous month 00:00 - 1st of this month 00:00”.
What is confusing me is that “this month” works as I want it to, and "Created > ‘this month’ " will show all tickets created after the 1st of this month 00:00, but there is no equivalent for a past tense? (That I know of)
I started thinking I could write a callback on the “Initial” in Search/Results.html to process the query string to add extra function to do this. I started this with the string “prior month” but then noticed that if I used this in a query first, RT logged that it couldn’t parse the date by both Time::ParseDateandDateTime::Format::Natural. Digging into the latter, it appears there are a lot more options for strings than are shown the Time::ParseDate module docs, espectially if you look in DateTime::Format::Natural::Lang::EN documentation.
So try this query string and see if it does what you want:
Queue = 'X' AND Created >= '1st day last month' AND Created < 'this month' AND Status = 'resolved'
It doesn’t appear to work. It gives this error message: Wrong query, expecting a AGGREGATOR in ‘Queue = ‘Helpdesk’ AND Created >= ‘1st >day<–here last month’ AND Created < ‘this month’ AND Status = ‘resolved’’
Doesn’t work. The “last month” always equals “31 days ago” instead of the concept of a calendar month that happened before the current calendar month. There for the equation doesn’t want to work as we want it to.