On 19/02/2020 04:59, Atila Rangel 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.
The to_char() function pads the weekday names with spaces, as you can
see with this query:
postgres=# select *, 'X' || to_char(some_date, 'day')::text || 'X' from
postgres_report_bug limit 5;
id | some_date | ?column?
----+------------------------+-------------
1 | 2019-11-11 00:00:00+02 | Xmonday X
2 | 2019-11-11 01:00:00+02 | Xmonday X
3 | 2019-11-11 02:00:00+02 | Xmonday X
4 | 2019-11-11 03:00:00+02 | Xmonday X
5 | 2019-11-11 04:00:00+02 | Xmonday X
(5 rows)
You can use 'FMday' instead of 'day' to avoid that.
- Heikki