X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 6BFE5D1DAB0 for ; Mon, 16 Feb 2004 13:18:50 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 05416-10 for ; Mon, 16 Feb 2004 09:18:51 -0400 (AST) Received: from rock.spider.ru (rock.spider.ru [62.183.34.226]) by svr1.postgresql.org (Postfix) with ESMTP id 1339DD1D3DC for ; Mon, 16 Feb 2004 09:18:48 -0400 (AST) Received: from rock (localhost [127.0.0.1]) by rock (Postfix) with SMTP id 1772091285 for ; Mon, 16 Feb 2004 16:18:51 +0300 (MSK) Received: from sad.localnet.ru (sad.localnet.ru [10.0.0.33]) by rock.spider.ru (Postfix) with ESMTP id E7A2191267 for ; Mon, 16 Feb 2004 16:18:50 +0300 (MSK) Content-Type: text/plain; charset="iso-8859-1" From: sad Organization: IT To: pgsql-sql@postgresql.org Subject: Re: Getting the week of a date Date: Mon, 16 Feb 2004 16:23:24 +0300 User-Agent: KMail/1.4.3 References: <00f701c3f485$d7091430$7502a8c0@hdsc.com> <20040216054320.32df9226.Robert_Creager@LogicalChaos.org> In-Reply-To: <20040216054320.32df9226.Robert_Creager@LogicalChaos.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200402161623.24195.sad@bankir.ru> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/198 X-Sequence-Number: 16888 EXCUSE ME, GUYS ! i forgot to add one monome: 7*(((to_char(date_trunc('month',now()),'D'))::INT2-1)/4) which is stands for skip a first week of month in case it is not consist Wed finally the select will be similar the following SELECT 7*(((to_char(date_trunc('month',now()),'D'))::INT2-1)/4) + 1 -=20 (to_char(date_trunc('month',now()),'D'))::INT2 + 7*3-3 ; 4 - is a number of Wed in a week (in postgresql numeration)