Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1B910475FF1 for ; Thu, 24 Oct 2002 06:52:47 -0400 (EDT) Received: from krogh.officenet.no (unknown [193.212.174.45]) by postgresql.org (Postfix) with ESMTP id 0D99F475BD7 for ; Thu, 24 Oct 2002 06:52:46 -0400 (EDT) Received: from krogh.officenet.no (localhost.localdomain [127.0.0.1]) by krogh.officenet.no (Postfix) with ESMTP id B09B122013 for ; Thu, 24 Oct 2002 06:51:35 -0400 (EDT) Content-Type: text/plain; charset="iso-8859-1" From: Andreas Joseph Krogh Organization: OfficeNet AS To: pgsql-sql@postgresql.org Subject: Problems with to_char(created, 'WW') Date: Thu, 24 Oct 2002 12:51:35 +0200 User-Agent: KMail/1.4.3 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200210241251.35365.andreak@officenet.no> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200210/330 X-Sequence-Number: 10047 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_accessed timestamp 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=3D# select created, to_char(created, 'WW') as week from session WHE= RE username IS NULL ORDER BY week; =20 created | week=20 ----------------------------+------ 2002-09-24 11:23:21.206+02 | 39 2002-09-24 18:19:06.304+02 | 39 2002-09-25 10:50:27.139+02 | 39 2002-09-30 12:32:06.898+02 | 39 2002-10-01 16:26:41.122+02 | 40 2002-10-04 13:47:02.922+02 | 40 2002-10-04 21:28:13.409+02 | 40 2002-10-04 17:35:50.954+02 | 40 2002-10-04 23:31:27.566+02 | 40 2002-10-04 23:34:18.286+02 | 40 2002-10-07 13:48:14.275+02 | 40 2002-10-07 13:50:04.352+02 | 40 2002-10-07 14:10:01.441+02 | 40 2002-10-11 12:57:53.458+02 | 41 2002-10-11 13:24:49.124+02 | 41 2002-10-13 16:26:52.546+02 | 41 2002-10-14 23:50:51.131+02 | 41 2002-10-15 14:54:12.341+02 | 42 2002-10-15 15:09:36.84+02 | 42 2002-10-15 15:21:26.59+02 | 42 2002-10-20 12:14:05.203+02 | 42 2002-10-20 20:19:44.309+02 | 42 2002-10-21 14:23:31.425+02 | 42 2002-10-22 12:12:31.63+02 | 43 2002-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= =20 43? --=20 Andreas Joseph Krogh - There are 10 kinds of people in the world, those that can do binary arithmetic and those that can't.