Subject Re: Error with TIMESTAMP field
Author mikcaau
--- In firebird-support@yahoogroups.com, "William Gonzáles S."
<wgonzaless@y...> wrote:
>
> Hello, the following query:
>
> SELECT WORK_DATE FROM OBJECTS_IN_WORK
> WHERE ((WORK_DATE >= '20050912') AND (WORK_DATE <
> '20050914'))
>
> (`WORK_DATE' is a TIMESTAMP field) it gives the error:
>
> " Overflow occurred during data type conversion.
> Conversion error from string `20050914' "
>

SELECT WORK_DATE FROM OBJECTS_IN_WORK
WHERE WORK_DATE between '12-may-2005' AND '14-apr-2005'

In addition hB put me onto this.
In a dialect 3 database this will NOT return rows where work_date is
on 14-apr-2005.
The solution is to use

SELECT WORK_DATE FROM OBJECTS_IN_WORK
WHERE cast(WORK_DATE as date) between '12-may-2005' AND '14-apr-2005'

A dialect 1 db has a similar flaw.
cf The Firebird Book pg 156.

If you are calling this query from an application then I suggest that
you use ParamByName('Work_Date').asDateTime

mick