Received: from shaked.cc.openu.ac.il (shaked.cc.openu.ac.il [147.233.145.65]) by hub.org (8.9.3/8.9.3) with ESMTP id NAA20270 for ; Mon, 25 Oct 1999 13:13:53 -0400 (EDT) (envelope-from herouth@oumail.openu.ac.il) Received: from [147.233.159.109] (herouth@mac-herouth.pc.openu.ac.il [147.233.159.109]) by shaked.cc.openu.ac.il (8.8.8/8.8.8) with ESMTP id TAA29310; Mon, 25 Oct 1999 19:13:34 +0200 (IST) X-Sender: herouth@shaked.cc.openu.ac.il Message-Id: In-Reply-To: <3810C061.9E2DCE6C@zotconsulting.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Date: Mon, 25 Oct 1999 19:14:11 +0200 To: "Zot O'Connor" , postgres sql From: Herouth Maoz Subject: Re: [SQL] Week of year function? At 21:52 +0200 on 22/10/1999, Zot O'Connor wrote: > Is there a function to return the week of the year (0-51)? Seems you only need to divide the day of the year by seven to reach that, don't you? Maybe you should try: CREATE FUNCTION week( datetime ) RETURNS int4 AS ' SELECT int( date_part( ''day'', $1 - date_trunc( ''year'', $1 ) ) ) / 7 ' LANGUAGE 'sql'; Herouth -- Herouth Maoz, Internet developer. Open University of Israel - Telem project http://telem.openu.ac.il/~herutma