From: | Frank Heikens <frankheikens(at)mac(dot)com> |
---|---|
To: | Atila Rangel <atila(dot)rangel(at)cyberlabs(dot)com(dot)br> |
Cc: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: [Bug Report] Week Day |
Date: | 2020-02-19 09:07:34 |
Message-ID: | F8666474-1915-48EC-B943-DF300EE465A0@mac.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | 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(dot)rangel(at)cyberlabs(dot)com(dot)br <mailto:atila(dot)rangel(at)cyberlabs(dot)com(dot)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>
From | Date | Subject | |
---|---|---|---|
Next Message | Dmitry Dolgov | 2020-02-19 09:35:50 | Re: [Bus error] huge_pages default value (try) not fall back |
Previous Message | Heikki Linnakangas | 2020-02-19 09:07:04 | Re: [Bug Report] Week Day |