dbTalk Databases Forums  

Re: [BUGS] BUG #1458: to_char is crazy

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss Re: [BUGS] BUG #1458: to_char is crazy in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Alvaro Herrera
 
Posts: n/a

Default Re: [BUGS] BUG #1458: to_char is crazy - 02-03-2005 , 12:09 AM






On Wed, Feb 02, 2005 at 12:27:53AM +0000, Tomás Zandoná wrote:

Hey Tomás,

Quote:
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)

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo (AT) postgresql (DOT) org


Reply With Quote
  #2  
Old   
Theodore Petrosky
 
Posts: n/a

Default Re: [BUGS] BUG #1458: to_char is crazy - 02-03-2005 , 06:49 AM






There is only one row in the table?

Quote:
select to_char(day, 'DD/MM/YYYY') from test_table;
what happens with:

select * from test_table; or
select day from test_table;

What does your insert statement look like? What is the
column type?

Ted

--- Tomás Zandoná <tdzandona (AT) yahoo (DOT) com.br> wrote:

Quote:
The following bug has been logged online:

Bug reference: 1458
Logged by: Tomás Zandoná
Email address: tdzandona (AT) yahoo (DOT) com.br
PostgreSQL version: 7.3.2
Operating system: i don't know
Description: to_char is crazy
Details:

I'm from brazil. I don't wrote English very well.

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...

Can you help me?
I'm waiting for an answare.
Thanks,
Tomás Zandoná.

---------------------------(end of
broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq



__________________________________
Do you Yahoo!?
Meet the all-new My Yahoo! - Try it today!
http://my.yahoo.com



---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster


Reply With Quote
  #3  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] BUG #1458: to_char is crazy - 02-03-2005 , 11:14 AM



"Tomás Zandoná" <tdzandona (AT) yahoo (DOT) com.br> writes:
Quote:
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.
What timezone are you using, and is midnight 2005-10-09 a
daylight-savings transition time there? If so, this is a known bug
in PG 7.3 --- update to 7.4 or later to fix it. As a workaround you
could explicitly cast the date value to timestamp without time zone
before feeding it to to_char.

My Fedora machine thinks that the October 2005 transition day in Brazil
is the 16th, but you might be using a different timezone database. 7.3
gets the promotion from date to timestamp-with-zone wrong:

regression=# set TimeZone TO 'America/Sao_Paulo';
SET
regression=# select ('2005-10-16'::date)::timestamp with time zone;
timestamptz
------------------------
2005-10-15 23:00:00-03
(1 row)

7.4 and later produce '2005-10-16 01:00:00-02' which is more reasonable
(the point being that local midnight doesn't actually exist due to the
DST spring forward).

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.