Subject Re: [ib-support] Jaybird JAVA date conversion problem
Author Blas Rodriguez Somoza
Hello

At 10/01/2003 12:12 +0100, you wrote:
>Dear Guys
>I have problems to work with data in Jaybird- JDBC !
>Fiebird and WebObjects and Jaybird 1.3.1
>
>How to work something like that:
>
>select * from table1 where my_date <> "17.11.1858" (or null or a
>special date my birthday "09.04.1961" or other date)
>the same here "... where my_date <> '1858-11-17 00:00:00 +0000' ...
>
>the driver raises an error :
>conversion error from string "1858-11-17 00:00:00 +0000"

This is not a JayBird error, if you try with IBAccess you will see the same error.

The format for a literal Timestamp value is 'yyyy-mm-dd hh:mm:ss' but does not allow milliseconds. The correct query is

where my_date <> '1858-11-17 00:00:00'

To avoid those conversion problems, simply use PreparedStatement with parameters

PreparedStatement ps = conn.prepareStatement("........... where my_date <> ?");
ps.setTimestamp(1, ........);

Don't include literals values in querys, use parameters, this way Jaybird will take care of the conversion.

Regards
Blas Rodriguez Somoza