X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A014CD7231 for ; Mon, 22 Aug 2005 17:39:50 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 33870-10 for ; Mon, 22 Aug 2005 20:39:48 +0000 (GMT) Received: from mail.digitalfairway.ca (ns.digitalfairway.ca [207.164.133.170]) by svr1.postgresql.org (Postfix) with ESMTP id 3BA1ED710B for ; Mon, 22 Aug 2005 17:39:47 -0300 (ADT) Received: from toronto.toronto.digitalfairway.ca (unknown [192.168.100.10]) by mail.digitalfairway.ca (Postfix) with ESMTP id EB689A055E for ; Mon, 22 Aug 2005 16:39:44 -0400 (EDT) Received: from localhost (toronto.toronto.digitalfairway.ca [127.0.0.1]) by toronto.toronto.digitalfairway.ca (Postfix) with ESMTP id 9CE1FA130F for ; Mon, 22 Aug 2005 16:39:44 -0400 (EDT) Received: from toronto.toronto.digitalfairway.ca ([127.0.0.1]) by localhost (toronto.toronto.digitalfairway.ca [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 07861-10 for ; Mon, 22 Aug 2005 16:39:44 -0400 (EDT) Received: from [192.168.100.50] (unknown [192.168.100.50]) (using SSLv3 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by toronto.toronto.digitalfairway.ca (Postfix) with ESMTP id 842DDA130E for ; Mon, 22 Aug 2005 16:39:44 -0400 (EDT) From: Jan de Visser To: pgsql-jdbc@postgresql.org Subject: Re: Problem with to_date function Date: Mon, 22 Aug 2005 16:39:42 -0400 User-Agent: KMail/1.8.2 References: <430A2827.9060907@secad.to.gov.br> In-Reply-To: <430A2827.9060907@secad.to.gov.br> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200508221639.42844.jdevisser@digitalfairway.com> X-Virus-Scanned: amavisd-new at digitalfairway.ca X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.044 required=5 tests=[AWL=-0.006, FORGED_RCVD_HELO=0.05] X-Spam-Level: X-Archive-Number: 200508/167 X-Sequence-Number: 13736 On Monday 22 August 2005 15:31, Gilberto C Andrade wrote: > Hi, > > I would like to know if the following is the expected result: > from psql: > bcoproducao=3D# select to_date(current_date, 'DD/MM/YYYY'), current_date; > to_date | date > ------------+------------ > 22/08/2005 | 22/08/2005 > (1 row) > > from my jdbc code: > rs =3D stmt.executeQuery("select to_date(current_date, > 'DD/MM/YYYY'), current_date"); > while (rs.next()) { > System.out.println(rs.getString(1) + " | " > +rs.getString(2)); > } > result: > 0028-01-26 | 2005-08-22 Hate to burst your bubble: psql=3D# select to_date(current_date, 'DD/MM/YYYY'), current_date; to_date | date =2D-----------+------------ 0028-01-26 | 2005-08-22 (1 row) So there is something fishy with your use of to_date, most likely because=20 current_date is already of type DATE, and TO_DATE expects a string as it's= =20 first parameter. Lemme see: psql=3D# select cast( current_date as text ); text =2D----------- 2005-08-22 (1 row) psql=3D# select to_date( '2005-08-22', 'DD/MM/YYYY'); to_date =2D----------- 0028-01-26 (1 row) So there you have it... I think that basically you don't need that to_date at all, since you alread= y=20 have a date... JdV!! > > Any advice here? > Thanks! > Gilberto > > > > ---------------------------(end of broadcast)--------------------------- > TIP 3: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faq =2D-=20 =2D------------------------------------------------------------- Jan de Visser =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 jdevisser@digitalfair= way.com =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Baruk Khazad! Khazad ai-menu! =2D-------------------------------------------------------------