Re: Year 2024: Extracting week from date gives wrong results for the last two days of the year

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Michael Monscheuer <mm(at)digiperience(dot)de>
Cc: Pg Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: Year 2024: Extracting week from date gives wrong results for the last two days of the year
Date: 2018-07-04 14:13:43
Message-ID: CAMkU=1z3kvz_Nv9TmZ1Xii8svhvPA4=BkZAujS5+G-Ta6jjKAw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, Jul 4, 2018 at 9:55 AM, Michael Monscheuer <mm(at)digiperience(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Félix GERZAGUET 2018-07-04 14:14:13 Re: Year 2024: Extracting week from date gives wrong results for the last two days of the year
Previous Message Michael Monscheuer 2018-07-04 13:55:54 Year 2024: Extracting week from date gives wrong results for the last two days of the year