Subject Re: [firebird-support] extract(week from d)
Author Stefan Heymann
Helen,

> Just looking at my [...] diary for 2006, for example, I see that
> January 1 2006 was the last day in Week 52 of 2005...and that Week 1
> started on January 2. [...] My Collins diary for 2007 has Jan 1 in
> Week 1. But - oh - my Collins diary for 2005 has Jan 1 AND Jan 2 in
> Week 53.

That's the correct ISO week and it's consistent with the system we use
here in Germany. The first week in a year that has more days in the
new year than in the old year is week 1. That means that the first
Thursday in a new year determines week 1, because the larger "half" of
a week begins with thursday (Mon,Tue,Wed | Thu,Fri,Sat,Sun). (And
that's why there is the word "thursday" in Ivan's code.)

This means that:
- Week 1 can begin in the old year
- Week 1 can begin later than January 1 (and the last week of the old
year reaches into the new year)
- A year can have 52 or 53 weeks

And it especially means that:
The week no. is worthless without a *corresponding* year no. Because
January 1 of 2006 is in Week 53 of 2005.

So a correct implementation of the "week system" in the EXTRACT clause
would mean that there should be two clauses:
extract (week from d) and
extract (weekyear from d)

Best Regards

Stefan (it's currently week 48/2006 here :-)


--
Stefan Heymann
www.destructor.de/firebird