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

From: Nick Memos <memnik(at)hotmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "pgsql-bugs(at)lists(dot)postgresql(dot)org" <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 22:57:49
Message-ID: VI1PR06MB32005E0B676E461C65F983F2C6040@VI1PR06MB3200.eurprd06.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Ok thanks Tom!

Αποκτήστε το Outlook για Android<https://aka.ms/ghei36>

________________________________
From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Sent: Thursday, January 30, 2020 6:27:02 PM
To: memnik(at)hotmail(dot)com <memnik(at)hotmail(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #16238: Function " to_char(timestamp, text) " doesn't work properly

PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
> 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.

No, that's behaving as expected and documented. If you don't want
fixed-width output, use the FM prefix:

=# select to_char('2020-01-31'::date,'-Day-');
to_char
-------------
-Friday -
(1 row)

=# select to_char('2020-01-31'::date,'-FMDay-');
to_char
----------
-Friday-
(1 row)

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Ted Liu 2020-01-30 23:04:57 auto_explain logs ERROR: 08P01 for every query using bind variable
Previous Message Arseny Sher 2020-01-30 21:22:46 Re: ERROR: subtransaction logged without previous top-level txn record