Re: BUG #1458: to_char is crazy - Mailing list pgsql-bugs

From Alvaro Herrera
Subject Re: BUG #1458: to_char is crazy
Date
Msg-id 20050203054031.GA27145@dcc.uchile.cl
Whole thread Raw
In response to BUG #1458: to_char is crazy  ("Tomás Zandoná" <tdzandona@yahoo.com.br>)
List pgsql-bugs
On Wed, Feb 02, 2005 at 12:27:53AM +0000, Tomás Zandoná wrote:

Hey Tomás,

> I dont't know if it's a bug, but I insert the date 2005-10-09 in a Date
> field.
> Later I execute:
>
> select to_char(day, 'DD/MM/YYYY') from test_table;
>
> It returns 08/10/2005.
>
> ????? I don't understand why it returns 08 instead of 09...

Is the column of type timestamp or something similar?  If so, probably
you are being bitten by a timezone problem.  If you want just a date,
declare the column with type date.

--
Alvaro Herrera (<alvherre[@]dcc.uchile.cl>)
Bob [Floyd] used to say that he was planning to get a Ph.D. by the "green
stamp method," namely by saving envelopes addressed to him as 'Dr. Floyd'.
After collecting 500 such letters, he mused, a university somewhere in
Arizona would probably grant him a degree.              (Don Knuth)

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #1455: pg_dumpall fails
Next
From: Peter Eisentraut
Date:
Subject: Re: BUG #1454: error in "select * from table where a1 like '%\%%' " ???