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

From: hubert depesz lubaczewski <depesz(at)depesz(dot)com>
To: memnik(at)hotmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #16238: Function " to_char(timestamp, text) " doesn't work properly
Date: 2020-01-30 12:48:23
Message-ID: 20200130124823.GA7512@depesz.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Paquier 2020-01-30 13:06:37 Re: Bug in display of commit logs on git.postgresql.org
Previous Message hubert depesz lubaczewski 2020-01-30 12:02:46 Bug in display of commit logs on git.postgresql.org