Re: Year 2024: Extracting week from date gives wrong results for thelast two days of the year - Mailing list pgsql-bugs

From Jeff Janes
Subject Re: Year 2024: Extracting week from date gives wrong results for thelast two days of the year
Date
Msg-id CAMkU=1z3kvz_Nv9TmZ1Xii8svhvPA4=BkZAujS5+G-Ta6jjKAw@mail.gmail.com
Whole thread Raw
In response to Year 2024: Extracting week from date gives wrong results for the lasttwo days of the year  (Michael Monscheuer <mm@digiperience.de>)
List pgsql-bugs


On Wed, Jul 4, 2018 at 9:55 AM, Michael Monscheuer <mm@digiperience.de> wrote:
Team,

Extracting the week from a date gives wrong results for the last two days of 2024.

SELECT EXTRACT (WEEK FROM DATE '20241230');

or

SELECT EXTRACT (WEEK FROM DATE '20241231');

both result in a value of  1
which is wrong, obviously...


Not wrong.  See the docs:

By definition, ISO weeks start on Mondays and the first week of a year contains January 4 of that year.
 
So the first week of 2025 contains some days from 2024.

Cheers,

Jeff

pgsql-bugs by date:

Previous
From: Michael Monscheuer
Date:
Subject: Year 2024: Extracting week from date gives wrong results for the lasttwo days of the year
Next
From: Félix GERZAGUET
Date:
Subject: Re: Year 2024: Extracting week from date gives wrong results for thelast two days of the year