Re: Problem with to_date function

From: Kris Jurka <books(at)ejurka(dot)com>
To: Gilberto C Andrade <gilbertoca(at)secad(dot)to(dot)gov(dot)br>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Problem with to_date function
Date: 2005-08-22 20:49:45
Message-ID: Pine.BSO.4.62.0508221544230.25580@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Joost Kraaijeveld 2005-08-23 09:55:14 Is this error correct/possible?
Previous Message Jan de Visser 2005-08-22 20:39:42 Re: Problem with to_date function