Re: Problem with to_date function
От | Jan de Visser |
---|---|
Тема | Re: Problem with to_date function |
Дата | |
Msg-id | 200508221639.42844.jdevisser@digitalfairway.com обсуждение исходный текст |
Ответ на | Problem with to_date function (Gilberto C Andrade <gilbertoca@secad.to.gov.br>) |
Список | 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@digitalfairway.com Baruk Khazad! Khazad ai-menu! --------------------------------------------------------------
В списке pgsql-jdbc по дате отправления: