Re: BUG #13845: Incorrect week number - Mailing list pgsql-bugs

From Feike Steenbergen
Subject Re: BUG #13845: Incorrect week number
Date
Msg-id CAK_s-G2b=rtj99RNXj8mQzLbQUsZ12bMsg8yEEYdAssj7K5gmw@mail.gmail.com
Whole thread Raw
In response to Re: BUG #13845: Incorrect week number  ("Shulgin, Oleksandr" <oleksandr.shulgin@zalando.de>)
List pgsql-bugs
If I read and understand the documentation correctly, WW starts on the
first day of the year, therefore January 1 - 7 is week 01.

The following query seems to confirm this on 9.4, I'm looking for the week
number for day 7 of the year:

# # select to_char(day, 'YYYYWW') as week, to_char(day, 'IYYYIW') as
isoweek from generate_series('2008-01-07','2020-01-07', interval '1 year')
as series(day);
  week  | isoweek
--------+---------
 200801 | 200802
 200901 | 200902
 201001 | 201001
 201101 | 201101
 201201 | 201201
 201301 | 201302
 201401 | 201402
 201501 | 201502
 201601 | 201601
 201701 | 201701
 201801 | 201801
 201901 | 201902
 202001 | 202002
(13 rows)

According to wikipedia, the US weeks starts on a Sunday, it would already
have resulted in differences when using the WW format for weeks in the
past, as WW starts on day 1, whether it is Sunday or Wednesday.

regards,

Feike

pgsql-bugs by date:

Previous
From: "Shulgin, Oleksandr"
Date:
Subject: Re: BUG #13845: Incorrect week number
Next
From: Tom Lane
Date:
Subject: Re: BUG #13845: Incorrect week number