From: | Jan de Visser <jdevisser(at)digitalfairway(dot)com> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: Problem with to_date function |
Date: | 2005-08-22 20:39:42 |
Message-ID: | 200508221639.42844.jdevisser@digitalfairway.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
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=# 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 = 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=# select to_date(current_date, 'DD/MM/YYYY'), current_date;
to_date | date
------------+------------
0028-01-26 | 2005-08-22
(1 row)
So there is something fishy with your use of to_date, most likely because
current_date is already of type DATE, and TO_DATE expects a string as it's
first parameter.
Lemme see:
psql=# select cast( current_date as text );
text
------------
2005-08-22
(1 row)
psql=# select to_date( '2005-08-22', 'DD/MM/YYYY');
to_date
------------
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 already
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
--
--------------------------------------------------------------
Jan de Visser jdevisser(at)digitalfairway(dot)com
Baruk Khazad! Khazad ai-menu!
--------------------------------------------------------------
From | Date | Subject | |
---|---|---|---|
Next Message | Kris Jurka | 2005-08-22 20:49:45 | Re: Problem with to_date function |
Previous Message | Kris Jurka | 2005-08-22 20:15:45 | Re: Problem with to_date function |