Re: [Bug Report] Week Day - Mailing list pgsql-bugs

From Frank Heikens
Subject Re: [Bug Report] Week Day
Date
Msg-id F8666474-1915-48EC-B943-DF300EE465A0@mac.com
Whole thread Raw
In response to [Bug Report] Week Day  (Atila Rangel <atila.rangel@cyberlabs.com.br>)
List pgsql-bugs
It’s not a bug, this is how to_char() works. From the manual: 
day full lower case day name (blank-padded to 9 chars)

It returns 9 characters. And only wednesday is without blanks. Change your where condition to solve the problem.

WITH testcases AS (
SELECT dd
FROM generate_series('2019-11-11'::timestamp, now(), '1 day'::interval) dd
)
SELECT 
dd, to_char(dd, 'day'), length(to_char(dd, 'day'))
FROM testcases
WHERE to_char(dd, 'day') IN('monday   ','tuesday  ')
OR to_char(dd, 'day') =ANY('{"friday   "}'::text[]);

Abraço,
Frank


On 19 Feb 2020, at 03:59, Atila Rangel <atila.rangel@cyberlabs.com.br> wrote:

Hi, I'm a software developer working with Postgresql database. Recently, I have had a issue with Week Day queries. Basically, I tried to filter some datetime based on day of week name. I'm sending a sql that you can reproduce the bug. This may not be a bug. But, I would like to report this.


--

<postgres_bug_report.sql>

pgsql-bugs by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: [Bug Report] Week Day
Next
From: Dmitry Dolgov
Date:
Subject: Re: [Bus error] huge_pages default value (try) not fall back