Query Help Please

My query:

‘Queue = “CustomerCare” AND ((Status = “open” AND LastUpdate > $startDate) OR
(Status = “resolved” AND Resolved > $startDate))’

This, unfortunately, returns all resolved tickets (I’m not sure what it returns
for open tickets). How can I modify this to only return tickets that are open
and updated according to the date held in $startDate and/or are resolved and
have been resolved according to the date held in $startDate?

For the record, the date is one week prior to the day the script is run.

Mathew

Seriously, can someone help please? This is getting frustrating.

Mathew

Mathew Snyder wrote:

This is what’s in Query Builder:

Queue = ‘CustomerCare’ AND ( LastUpdated > ‘2007-03-23’ OR Resolved >
‘2007-03-23’ )

It returns 168 tickets.

This is what I have in the script:
“Queue = ‘CustomerCare’ AND (LastUpdated > '” . $startDate . “’ OR Resolved > '”
. $startDate . “’)”

It returns 0 tickets.

Mathew Snyder wrote:

Is the date format correct in $startDate, ie. does $startDate
equal ‘2007-03-23’ exactly? That’s the only possible difference, right?
If you turn on full SQL logs, what query do you see being run?On Fri, 30 Mar 2007, Mathew Snyder wrote:

This is what’s in Query Builder:

Queue = ‘CustomerCare’ AND ( LastUpdated > ‘2007-03-23’ OR Resolved >
‘2007-03-23’ )

It returns 168 tickets.

This is what I have in the script:
“Queue = ‘CustomerCare’ AND (LastUpdated > '” . $startDate . “’ OR Resolved > '”
. $startDate . “')”

It returns 0 tickets.

Mathew Snyder wrote:

My query:

‘Queue = “CustomerCare” AND ((Status = “open” AND LastUpdate > $startDate) OR
(Status = “resolved” AND Resolved > $startDate))’

This, unfortunately, returns all resolved tickets (I’m not sure what it returns
for open tickets). How can I modify this to only return tickets that are open
and updated according to the date held in $startDate and/or are resolved and
have been resolved according to the date held in $startDate?

For the record, the date is one week prior to the day the script is run.

Mathew


The rt-users Archives

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com


The rt-users Archives

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

Mathew,

I'm not a perl expert by any stretch, but I've coded in over 25 

different languages over several decades (I’m really old) so my comments
are in relation to the conditional logic, not syntax. It seems to me as
I look at the “OR Resolved > $StartDate” part, you will always get a
positive result. Reason: I do not think it is possible to have a start
date less than the resolved date and since the logic said “OR” it will
always meet that condition. This is also based on the assumption that
the date formats are consistent. Just a thought.

Kenn
LBNL

Mathew Snyder wrote:

I am, in fact, getting errors.

070330 23:02:55 [ERROR] /usr/libexec/mysqld: Incorrect information in file:
’./rt3_devel/Users.frm’
070330 23:02:55 [ERROR] /usr/libexec/mysqld: Incorrect information in file:
’./rt3_devel/Queues.frm’
070330 23:02:55 [ERROR] /usr/libexec/mysqld: Incorrect information in file:
’./rt3_devel/Tickets.frm’

Jon Daley wrote:

I got it all sorted out. Thanks.

Jon Daley wrote:

How do I do a query that searches for a range up to and including a date?

I have this:
Queue = ‘CustomerCare’ AND ( ( LastUpdated < ‘2007-04-07’ AND LastUpdated >
‘2007-04-01’ ) OR ( LastUpdated = ‘2007-04-01’ AND LastUpdated = ‘2007-04-07’ ) )

But it’s returning 0 results. If I change the ‘OR’ to an ‘AND’ it still returns
0. Using ‘>=’ and ‘<=’ doesn’t work either.

Mathew

Mathew Snyder wrote:

Mathew, how it’s possible that the same date field equal to
‘2007-04-01’ and ‘2007-04-07’ at the same time?On 4/8/07, Mathew Snyder theillien@yahoo.com wrote:

How do I do a query that searches for a range up to and including a date?

I have this:
Queue = ‘CustomerCare’ AND ( ( LastUpdated < ‘2007-04-07’ AND LastUpdated >
‘2007-04-01’ ) OR ( LastUpdated = ‘2007-04-01’ AND LastUpdated = ‘2007-04-07’ ) )

But it’s returning 0 results. If I change the ‘OR’ to an ‘AND’ it still returns
0. Using ‘>=’ and ‘<=’ doesn’t work either.

Mathew

Mathew Snyder wrote:

My query:

‘Queue = “CustomerCare” AND ((Status = “open” AND LastUpdate > $startDate) OR
(Status = “resolved” AND Resolved > $startDate))’

This, unfortunately, returns all resolved tickets (I’m not sure what it returns
for open tickets). How can I modify this to only return tickets that are open
and updated according to the date held in $startDate and/or are resolved and
have been resolved according to the date held in $startDate?

For the record, the date is one week prior to the day the script is run.

Mathew


The rt-users Archives

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com


The rt-users Archives

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

Best regards, Ruslan.

Haha! Good question. Lemme consult the string theorists and get back to you :wink:

Actually, I fixed it by using OR (LastUpdated = ‘2007-04-01’ OR LastUpdated =
‘2007-04-07’)

Mathew

Ruslan Zakirov wrote: