Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TO_CHAR Issue or Designed feature

6 views
Skip to first unread message

Thomas Morgan

unread,
Jan 29, 2024, 5:22:16 PM1/29/24
to
When I issue following

SELECT to_char(now(), 'Hh24') Current_Hour;

I get:

current_hour
--------------
Hh24
(1 row)

Is this documented or it it a flaw. Should it be doing the format case insensitive?

Thanks,
Thomas

John-Paul Stewart

unread,
Jan 29, 2024, 7:06:50 PM1/29/24
to
Although it is not explicitly stated, the format string must be case
sensitive. You can infer that from the following table:

https://www.postgresql.org/docs/15/functions-formatting.html#FUNCTIONS-FORMATTING-DATETIME-TABLE

Note the difference between "AM" and "am", or "MONTH" and "Month" and
"month". (To name just two examples.) Based on that, it should be
obvious that the pattern has to be interpreted in a case sensitive manner.
0 new messages