BUG #16238: Function " to_char(timestamp, text) " doesn't work properly

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: memnik(at)hotmail(dot)com
Subject: BUG #16238: Function " to_char(timestamp, text) " doesn't work properly
Date: 2020-01-30 11:49:45
Message-ID: 16238-3008a3b37b41cb0e@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 16238
Logged by: Nick Memos
Email address: memnik(at)hotmail(dot)com
PostgreSQL version: 10.7
Operating system: Windows 10
Description:

Hello,
I have created a table with a json column. Where in this json i have some
details for each day of the week. It is something like this '{"Monday":
13,"Tuesday": 13,"Wednesday": 13, "Thursday ": 12, "Friday": 13,"Saturday":
13,"Sunday": 13}'::json.
So, when i try to get the information for each day by this way: '{"Monday":
13,"Tuesday": 13,"Wednesday": 13, "Thursday ": 12, "Friday": 13,"Saturday":
13,"Sunday": 13}'::json->>to_char(current_timestamp,'Day') , i don't get the
results for all days. As i noticed the problem is that the function "
to_char(timestamp, text) " doesn't work properly. For example this query "
select to_char('2020-01-29'::date,'Day') " give me this result "Wednesday",
but this query " select to_char('2020-01-31'::date,'Day') " give me this
result "Friday ".
So, i guess it is not right to have days with many spaces as a result and
some days without any space.
Now i will user trim() function but it is better to fix that if it is
possible.
Thanks!

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message hubert depesz lubaczewski 2020-01-30 12:02:46 Bug in display of commit logs on git.postgresql.org
Previous Message Stéphane Campinas 2020-01-30 10:26:17 BUG #16236: Invalid escape encoding