Subject Another bug in Firebird 2.1.1
Author trtoms
This query fails in Firebird 2.1.1 -

SELECT COMPANYID, ICDESCRIPTION, PRODUCTID, PRODUCTNAME,
SUM(ISCOMPLETE) CLOSED, SUM(ISNEW) OPENED, SUM(HASDURATION)
HASDURATION, (CASE WHEN SUM(HASDURATION) > 0 THEN SUM(DURATION) /
SUM(HASDURATION) ELSE 0 END) DURATION,
SUM(SLA1) SLA1, SUM(SLA2) SLA2, SUM(SLA7) SLA7, SUM(SLAOTHER) SLAOTHER
FROM (
SELECT C.COMPANYID, CUO.USERNAME, IC.ICDESCRIPTION, P.PRODUCTID,
P.PRODUCTNAME,
(CASE WHEN IV.NEWDATE BETWEEN '10/21/2008' AND '10/29/2008 23:59:59'
THEN 1 ELSE 0 END) ISNEW,
(CASE WHEN IV.COMPLETIONDATE BETWEEN '10/21/2008' AND '10/29/2008
23:59:59' THEN 1 ELSE 0 END) ISCOMPLETE,
(CASE WHEN IV.COMPLETIONDATE IS NOT NULL THEN 1 ELSE 0 END) HASDURATION,
(CASE WHEN IV.COMPLETIONDATE BETWEEN '10/21/2008' AND '10/29/2008
23:59:59' THEN IV.COMPLETIONDATE - IV.NEWDATE ELSE 0 END) DURATION,
(CASE WHEN IV.COMPLETIONDATE BETWEEN '10/21/2008' AND '10/29/2008
23:59:59' AND IV.COMPLETIONDATE - IV.NEWDATE < 1.0 THEN 1 ELSE 0 END)
SLA1,
(CASE WHEN IV.COMPLETIONDATE BETWEEN '10/21/2008' AND '10/29/2008
23:59:59' AND IV.COMPLETIONDATE - IV.NEWDATE BETWEEN 1.0 AND 2.0 THEN
1 ELSE 0 END) SLA2,
(CASE WHEN IV.COMPLETIONDATE BETWEEN '10/21/2008' AND '10/29/2008
23:59:59' AND IV.COMPLETIONDATE - IV.NEWDATE BETWEEN 2.0 AND 7.0 THEN
1 ELSE 0 END) SLA7,
(CASE WHEN IV.COMPLETIONDATE BETWEEN '10/21/2008' AND '10/29/2008
23:59:59' AND IV.COMPLETIONDATE - IV.NEWDATE >= 7.0 THEN 1 ELSE 0 END)
SLAOTHER
FROM TMISSUES I
INNER JOIN TMVISSUESTATUS IV ON IV.ISSUEID = I.ISSUEID
INNER JOIN TMEVENTS EVT ON EVT.EVENTID = I.ORIGINATINGEVENTID
INNER JOIN TMUSERS CUO ON CUO.USERID = I.CURRENTUSERID
INNER JOIN TMISSUECATEGORIES IC ON IC.ISSUECATEGORYID = I.ISSUECATEGORYID
LEFT OUTER JOIN (TMPRODUCTVERSIONS PV INNER JOIN TMPRODUCTS P ON
P.PRODUCTID = PV.PRODUCTID) ON PV.PRODUCTVERSIONID = I.PRODUCTVERSIONID
LEFT OUTER JOIN (TMUSERS CU INNER JOIN TMCOMPANYSITES CS ON
CS.COMPANYSITEID = CU.COMPANYSITEID
INNER JOIN TMCOMPANIES C ON C.COMPANYID = CS.COMPANYID)
ON CU.USERID = EVT.CLIENTUSERID
WHERE ((IV.NEWDATE BETWEEN '10/21/2008' AND '10/29/2008 23:59:59')
OR (IV.COMPLETIONDATE BETWEEN '10/21/2008' AND '10/29/2008
23:59:59'))
AND C.COMPANYID = 8
) AS TMSTATS
GROUP BY COMPANYID, ICDESCRIPTION, PRODUCTNAME, PRODUCTID
HAVING SUM(ISCOMPLETE) > 0 OR SUM(ISNEW) > 0
ORDER BY COMPANYID, ICDESCRIPTION, PRODUCTNAME, PRODUCTID

The error is:
Unsupported field type in BETWEEN predicate.

By changing the line:
WHERE ((IV.NEWDATE BETWEEN '10/21/2008' AND '10/29/2008 23:59:59')
OR (IV.COMPLETIONDATE BETWEEN '10/21/2008' AND '10/29/2008
23:59:59'))

to read:
WHERE ((IV.NEWDATE >= '10/21/2008' AND IV.NEWDATE <= '10/29/2008
23:59:59')
OR (IV.COMPLETIONDATE >= '10/21/2008' AND IV.COMPLETIONDATE <=
'10/29/2008 23:59:59'))

...the query now works. So how come all the other "between" operators
still work, yet they are exactly the same as the one that doesn't??

Puzzled,
Trevor