Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread Possible bug or issue with Week function
Tue, Feb 11 2014 7:20 AMPermanent Link

Adam Brett

Orixa Systems

If each of the following sql snipets are run:

CREATE TABLE Test
(DateDone Date);

INSERT INTO Test (DateDone) VALUES (DATE '2013-12-31');

SELECT
 EXTRACT(WEEK FROM DateDone)
FROM Test;

--

The SELECT returns "1" (on computers on my network anyway)

I believe the select should return 52 (the final week of the year)??

Is this an EDB BUG, or have I made a stupid mistake?
Tue, Feb 11 2014 7:26 AMPermanent Link

Adam Brett

Orixa Systems

I am using EDB 2.13.

I can see that

2013-12-28 returns week 52,
2013-12-29
2013-12-30
2013-12-31 all return week "1", but year 2013.

Surely these dates should either be week 53, or week 52. Otherwise, sums using these week numbers end up in figures for January of that year.
Tue, Feb 11 2014 10:00 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Adam,

<< I believe the select should return 52 (the final week of the year)??

Is this an EDB BUG, or have I made a stupid mistake? >>

From the manual:

"All day and week values returned from EXTRACT follow the ISO 8601 standard
for day and week numbers."

http://stackoverflow.com/questions/274861/how-do-i-calculate-the-week-number-given-a-date

Specifically (from the answers):

"ISO 8601 defines a standard for the representation of dates, times and time
zones. It defines weeks that start on a Monday. It also says Week 1 of a
year is the one which contains at least 4 days from the given year.
Consequently, the 29th, 30th and 31st of December 20xx could be in week 1 of
20xy (where xy = xx + 1), and the 1st, 2nd and 3rd of January 20xy could all
be in the last week of 20xx. Further, there can be a week 53."

Tim Young
Elevate Software
www.elevatesoft.com
Wed, Feb 12 2014 4:05 AMPermanent Link

Adam Brett

Orixa Systems

>>"All day and week values returned from EXTRACT follow the ISO 8601 standard
>>for day and week numbers."

Always with the ISO Standards ... Smile
Image