The uppercase 'TH' modifier is not working with HH12: template1=# select to_char('3-MAY-2007 2:34'::timestamptz,'FMHHTH" HOUR OF THE "FMDDTH" DAY WAS ILL-FATED'::text); to_char --------------------------------------- 2nd HOUR OF THE 3RD DAY WAS ILL-FATED (1 row)
Looking at the code, that looks like an oversight and the fix is trivial: --- a/src/backend/utils/adt/formatting.c +++ b/src/backend/utils/adt/formatting.c @@ -2094,7 +2094,7 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar * tm->tm_hour % (HOURS_PER_DAY / 2) == 0 ? 12 : tm->tm_hour % (HOURS_PER_DAY / 2)); if (S_THth(n->suffix)) - str_numth(s, s, 0); + str_numth(s, s, S_TH_TYPE(n->suffix)); s += strlen(s); break; case DCH_HH24: But given that it has been like that at least back to 8.0 which is the oldest version I have installed right now: does anyone see a reason not to fix that? -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs