Re: Problem with to_date function - Mailing list pgsql-jdbc

From Kris Jurka
Subject Re: Problem with to_date function
Date
Msg-id Pine.BSO.4.62.0508221544230.25580@leary.csoft.net
Whole thread Raw
In response to Problem with to_date function  (Gilberto C Andrade <gilbertoca@secad.to.gov.br>)
List pgsql-jdbc

On Mon, 22 Aug 2005, Gilberto C Andrade wrote:

> ALTER DATABASE bcoproducao SET DateStyle=sql, european;
> ALTER DATABASE bcoproducao SET client_encoding=latin1;
>
> So, setting datestyle isn't the problem.

Yes, it actually is.  Neither of the above settings will have any effect
because when the JDBC driver first connects to your database it will
overwrite these settings with ISO and UNICODE respectively.  You may
verify this by running "SHOW DateStyle" from a JDBC connection.  The
driver needs these settings to operate correctly.

> Other thing, I'm reporting this because we (www.secad.to.gov.br) have several
> reports (jasperreports) using to_date() function and all are returning wrong
> results.
>

I am unfamiliar with jasperreports, but I would suggest using
PreparedStatement.setDate which will correctly format your dates, or use
the ISO format for dates and the to_date format string.

Kris Jurka

pgsql-jdbc by date:

Previous
From: Kris Jurka
Date:
Subject: Re: Problem with to_date function
Next
From: Joost Kraaijeveld
Date:
Subject: Is this error correct/possible?