From: Frank Heikens <frankheikens@mac.com>
To: Atila Rangel <atila.rangel@cyberlabs.com.br>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: [Bug Report] Week Day
Date: Wed, 19 Feb 2020 10:07:34 +0100
Message-ID: <F8666474-1915-48EC-B943-DF300EE465A0@mac.com> (raw)
In-Reply-To: <CA+Ua9TtsZt96pV3CsTE6=Gb0HmfMQdpGdJLPxZRfb8dPuszw7Q@mail.gmail.com>
References: <CA+Ua9TtsZt96pV3CsTE6=Gb0HmfMQdpGdJLPxZRfb8dPuszw7Q@mail.gmail.com>
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 <mailto: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>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: frankheikens@mac.com, atila.rangel@cyberlabs.com.br
Subject: Re: [Bug Report] Week Day
In-Reply-To: <F8666474-1915-48EC-B943-DF300EE465A0@mac.com>
References: <CA+Ua9TtsZt96pV3CsTE6=Gb0HmfMQdpGdJLPxZRfb8dPuszw7Q@mail.gmail.com> <F8666474-1915-48EC-B943-DF300EE465A0@mac.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox