Date filter not working correctly

Forum for questions and support relating to the 1.24.x releases only.
Locked
kylejohnson
Posts: 260
Joined: Tue Aug 21, 2007 1:42 pm
Location: Baltimore, MD

Date filter not working correctly

Post by kylejohnson »

Some pseudo-code of what works and does not work...

Here are two filter examples of what works:

Code: Select all

MonitorName = "Front" AND Date >= 2010-05-03 AND Date <= 2010-05-05
This shows everything from 2010-05-03 to 2010-05-05 for Front

Code: Select all

MonitorName = "Front" AND Date >= 2010-05-03 AND Date <= 2010-05-03
This shows everything on 2010-05-03 for Front

Here are two examples of what does not work:

Code: Select all

MonitorName = "Front" OR MonitorName = "Back" AND Date >= 2010-05-03 AND Date <= 2010-05-05 

Code: Select all

MonitorName = "Front" OR MonitorName = "Back" AND Date >= 2010-05-03 AND Date <= 2010-05-03
For both examples, the date filter seems to be ignored - everything for Front and Back is returned, regardless of date.
And the actual SQL that ZM generates for one of the non-working filters:

Code: Select all

select E.Id,E.MonitorId,M.Name As MonitorName,M.Width,M.Height,M.DefaultScale,E.Name,E.MaxScore,E.StartTime,E.Length,E.Archived from Monitors as M inner join Events as E on (M.Id = E.MonitorId) where 1 and ( M.Name = 'Station_1' or M.Name = 'Test_Station' and to_days( E.StartTime ) >= to_days( '2010-05-05 00:00:00' ) and to_days( E.StartTime ) <= to_days( '2010-05-06 00:00:00' ) ) order by E.StartTime desc limit 0, 25
kwire
Posts: 48
Joined: Mon Jan 05, 2009 12:56 am
Location: Ada, Ohio, USA

Post by kwire »

Kyle,

I think you need to put some paren around your OR clause, like this...

Code: Select all

(MonitorName = "Front" OR MonitorName = "Back") AND Date >= 2010-05-03 AND Date <= 2010-05-05 
Keith
kylejohnson
Posts: 260
Joined: Tue Aug 21, 2007 1:42 pm
Location: Baltimore, MD

Post by kylejohnson »

kwire wrote:Kyle,

I think you need to put some paren around your OR clause, like this...

Code: Select all

(MonitorName = "Front" OR MonitorName = "Back") AND Date >= 2010-05-03 AND Date <= 2010-05-05 
Keith
That was it, my good man. Thank you!
Locked