Thread: BUG #17667: to_char is used to collect statistics by week

BUG #17667: to_char is used to collect statistics by week

From
PG Bug reporting form
Date:
The following bug has been logged on the website:

Bug reference:      17667
Logged by:          高成 卫
Email address:      1310290931@qq.com
PostgreSQL version: 14.1
Operating system:   PostgreSQL 14.1 on x86_64-pc-linux-musl, compiled
Description:

Week 42 of 2022 is October 17-23   

When I used ww to format the time, the 23rd was counted to week 43

When I used IW to format the time, the 23rd was counted to the 42nd week


Re: BUG #17667: to_char is used to collect statistics by week

From
Japin Li
Date:
On Thu, 27 Oct 2022 at 20:43, PG Bug reporting form <noreply@postgresql.org> wrote:
> The following bug has been logged on the website:
>
> Bug reference:      17667
> Logged by:          高成 卫
> Email address:      1310290931@qq.com
> PostgreSQL version: 14.1
> Operating system:   PostgreSQL 14.1 on x86_64-pc-linux-musl, compiled
> Description:
>
> Week 42 of 2022 is October 17-23
>
> When I used ww to format the time, the 23rd was counted to week 43
>
> When I used IW to format the time, the 23rd was counted to the 42nd week

The documentation about Template Patterns for Date/Time Formatting [1]
already descried this:

WW    week number of year (1–53) (the first week starts on the first day of the year)
IW    week number of ISO 8601 week-numbering year (01–53; the first Thursday of the year is in week 1)

[1] https://www.postgresql.org/docs/current/functions-formatting.html#FUNCTIONS-FORMATTING-DATETIME-TABLE

--
Regrads,
Japin Li.
ChengDu WenWu Information Technology Co.,Ltd.