Thread: Bugs in to_char function

Bugs in to_char function

From
"Tom Rogers"
Date:
I wanted to include the following in a select statement:

to_char(departtime, 'HH12:MI PM') as xdepart

This gives the correct meridian value for all AM times but incorrectly
returns an AM meridian for PM times between 12:00 PM and 1:50:59 PM.  If I
create the formatted Hours using 'HH24', the displayed 24 hour clock time is
correct.

I am using PostgreSQL version 7.0.2 on a RedHat Linux 6.2.

This is not a super critical problem for me because in this application it's
actually more correct for me to be using the 24 hour clock anyway, but I
just thought you might want to know about it.  I would like to know though,
whether this is legitimate and I hope I'm not trying to do this incorrectly.

Thank you
Tom Rogers

Re: Bugs in to_char function

From
Tom Lane
Date:
"Tom Rogers" <trogers3@creigh.com> writes:
> [to_char] gives the correct meridian value for all AM times but incorrectly
> returns an AM meridian for PM times between 12:00 PM and 1:50:59 PM.

I believe this is a known bug in the 7.0 implementation of to_char, and
is long since fixed in development sources.  Karel Zak is the author of
to_char and would know for sure.  Karel, does it make sense to
back-patch a quick fix for this into REL7_0_PATCHES for the upcoming
7.0.3 release?  If so, could you provide a patch?

            regards, tom lane

Re: Bugs in to_char function

From
Karel Zak
Date:
On Tue, 17 Oct 2000, Tom Rogers wrote:

> I wanted to include the following in a select statement:
>
> to_char(departtime, 'HH12:MI PM') as xdepart

 Very old story and already fixed in the current CVS. Wait for
great 7.1 :-)

                    Karel

PS. has this list some archive? - it's really frequent report...

Re: Bugs in to_char function

From
Karel Zak
Date:
On Tue, 17 Oct 2000, Tom Lane wrote:

> "Tom Rogers" <trogers3@creigh.com> writes:
> > [to_char] gives the correct meridian value for all AM times but incorrectly
> > returns an AM meridian for PM times between 12:00 PM and 1:50:59 PM.
>
> I believe this is a known bug in the 7.0 implementation of to_char, and
> is long since fixed in development sources.  Karel Zak is the author of
> to_char and would know for sure.  Karel, does it make sense to
> back-patch a quick fix for this into REL7_0_PATCHES for the upcoming
> 7.0.3 release?  If so, could you provide a patch?


 I look at "cvs co -P -r REL7_0_PATCHES pgsql" and it's worry,
the differention between 7.0.3 and 7.1 is in the formatting.c 5Kb :-(

 Well, I try prepare patch for 7.0.3 for AM/PM.

                        Karel