Subject Re: [firebird-support] Why a certain expression in 'where' throws an error?
Author Paul Vinkenoog
Hi kokok,

> SELECT * FROM Orders
> WHERE
> CAST(OrderDate + CAST((LfAvgDays+0.5) AS INTEGER) AS DATE) BETWEEN '2009/1/1' AND '2010/1/1'
>
> OrderDate is date type. LfAvgDays is float type. Why do I get error when I execute it?

Next time, please include the error message!

Anyway: you can't cast dates to integers. And you don't need a cast to add a float to a date. However, it will return a date, without time part.

Try:

where OrderDate + round(LfAvgDates) between '2009/1/1' and '2010/1/1'


HTH,
Paul Vinkenoog