Problems with to_char(created, 'WW') - Mailing list pgsql-sql

From Andreas Joseph Krogh
Subject Problems with to_char(created, 'WW')
Date
Msg-id 200210241251.35365.andreak@officenet.no
Whole thread Raw
Responses Re: Problems with to_char(created, 'WW')
List pgsql-sql
Hi.
I have the following schema in PostgreSQL-7.2.2:

CREATE TABLE session (session_id varchar(256) NOT NULL PRIMARY KEY,created timestamp DEFAULT 'now' NOT
NULL,last_accessedtimestamp NOT NULL,destroyed timestamp NOT NULL,username varchar -- Allow sessions from not logged in
users
);

Now I run this query to extract the week numbers:

janerik=# select created, to_char(created, 'WW') as week from session WHERE
username IS NULL ORDER BY week;         created           | week
----------------------------+------2002-09-24 11:23:21.206+02 | 392002-09-24 18:19:06.304+02 | 392002-09-25
10:50:27.139+02| 392002-09-30 12:32:06.898+02 | 392002-10-01 16:26:41.122+02 | 402002-10-04 13:47:02.922+02 |
402002-10-0421:28:13.409+02 | 402002-10-04 17:35:50.954+02 | 402002-10-04 23:31:27.566+02 | 402002-10-04
23:34:18.286+02| 402002-10-07 13:48:14.275+02 | 402002-10-07 13:50:04.352+02 | 402002-10-07 14:10:01.441+02 |
402002-10-1112:57:53.458+02 | 412002-10-11 13:24:49.124+02 | 412002-10-13 16:26:52.546+02 | 412002-10-14
23:50:51.131+02| 412002-10-15 14:54:12.341+02 | 422002-10-15 15:09:36.84+02  | 422002-10-15 15:21:26.59+02  |
422002-10-2012:14:05.203+02 | 422002-10-20 20:19:44.309+02 | 422002-10-21 14:23:31.425+02 | 422002-10-22 12:12:31.63+02
| 432002-10-23 14:00:18.478+02 | 43 
(25 rows)

Now - my question is, why is monday 21. in week 42, but tuesday 22. in week
43?

--
Andreas Joseph Krogh <andreak@officenet.no>
- There are 10 kinds of people in the world, those that can do binary arithmetic and those that can't.



pgsql-sql by date:

Previous
From: Tomasz Myrta
Date:
Subject: Re: sub-select with aggregate
Next
From: andres javier garcia garcia
Date:
Subject: ORDER the result of a query by date