Re: BUG #16238: Function " to_char(timestamp, text) " doesn't workproperly - Mailing list pgsql-bugs

From hubert depesz lubaczewski
Subject Re: BUG #16238: Function " to_char(timestamp, text) " doesn't workproperly
Date
Msg-id 20200130124823.GA7512@depesz.com
Whole thread Raw
In response to BUG #16238: Function " to_char(timestamp, text) " doesn't work properly  (PG Bug reporting form <noreply@postgresql.org>)
List pgsql-bugs
On Thu, Jan 30, 2020 at 11:49:45AM +0000, PG Bug reporting form wrote:
> 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.

First of all - it's not a bug - function works exactly as documented:
https://www.postgresql.org/docs/current/functions-formatting.html#FUNCTIONS-FORMATTING-DATETIME-TABLE
says:

"Day" -> full capitalized day name (blank-padded to 9 chars).

If you don't want the padding, use FM modifier, like:

select to_char('2020-01-31'::date,'FMDay');

Best regards,

depesz




pgsql-bugs by date:

Previous
From: hubert depesz lubaczewski
Date:
Subject: Bug in display of commit logs on git.postgresql.org
Next
From: Michael Paquier
Date:
Subject: Re: Bug in display of commit logs on git.postgresql.org