============================================================================ POSTGRESQL BUG REPORT TEMPLATE ============================================================================ Your name : Jaykumar Ahir Your email address : jay_ahir@hotmail.com System Configuration --------------------- Architecture (example: Intel Pentium) : Intel Celron Operating System (example: Linux 2.0.26 ELF) : Linux 2.2.14-12 PostgreSQL version (example: PostgreSQL-7.0): PostgreSQL-7.0.2 Compiler used (example: gcc 2.8.0) : egcs-2.91.66 Please enter a FULL description of your problem: ------------------------------------------------ The to_char() function of postgres doesn't gives correct result for the following SQL statement : SELECT to_char( timestamp('01-01-2000', time '13:00:00'),'HH12-MI PM'); Basically the the above SELECT to_char... gives perfectly Ok result for all input except for the time 01:00 PM or 13:00:00. It interpreted 13:00:00 as 01:00 AM instead of 01:00 PM. Please describe a way to repeat the problem. Please try to provide a concise reproducible example, if at all possible: ---------------------------------------------------------------------- following SQL statement : postgres=# select to_char( timestamp('01-01-2000', time '13:00:00'),'HH12-MI PM'); Sample Output is as follows: to_char ---------- 01-00 AM (1 row) If you know how this problem might be fixed, list the solution below: --------------------------------------------------------------------- I don't know whether this has been fixed or not or for that matter had any faced this problem before. I have found the fix for this bug. File : formatting.c Direcotry : /usr/src/postgresql-7.0.2/src/backed/utils/adt Line(s) with error : 1534, 1549, 1564, 1579 Do following Changes : Change line 1534 : strcpy(inout, (tm->tm_hour > 13 ? P_M_STR : A_M_STR)); to : strcpy(inout, (tm->tm_hour >= 13 ? P_M_STR : A_M_STR)); Change line 1549 : strcpy(inout, (tm->tm_hour > 13 ? PM_STR : AM_STR)); to : strcpy(inout, (tm->tm_hour >= 13 ? PM_STR : AM_STR)); Change line 1564 : strcpy(inout, (tm->tm_hour > 13 ? p_m_STR : a_m_STR)); to : strcpy(inout, (tm->tm_hour >= 13 ? p_m_STR : a_m_STR)); Change line 1579 : strcpy(inout, (tm->tm_hour > 13 ? pm_STR : am_STR)); to : strcpy(inout, (tm->tm_hour >= 13 ? pm_STR : am_STR)); That's all. Now rebuild and install. Sample Run after new build : postgres=# select to_char( timestamp('01-01-2000', time '13:00:00'),'HH12-MI PM'); Output is as follows: to_char ---------- 01-00 PM (1 row)