Subject Re: [firebird-support] Problems selecting on Timestamp.
Author Helen Borrie
At 07:45 AM 9/11/2011, canacourse wrote:


>How may I select items older than a certain epoch from a timestamp column? For example I have many records in a column using timestamp as the type and containing records such as:-
>
>'5.11.2011 23:34:21'
>'5.11.2011 08:34:00'
>'6.11.2011 19:55:45'
>'7.11.2011 15:23:26'
>
>However these queries produce no results even thought I can see records older then I'm looking for in the table
>
>select * FROM ENTRIES WHERE ENTRYTIME < '6/11/2011 08:34:26';
>
>or
>
>select * FROM ENTRIES WHERE ENTRYTIME < '6.11.2011 08:34:26';
>
>Firebird 2.6.5 Dialect 3

You need a cast expression or a hint to ensure that the conversion from the literal occurs:

select * FROM ENTRIES WHERE ENTRYTIME < (cast '6/11/2011 08:34:26 as timestamp)';
or
select * FROM ENTRIES WHERE ENTRYTIME < timestamp '6/11/2011 08:34:26';

./hb