Received: from linux2.johnmckown.net (adsl-64-216-1-125.dsl.eulstx.swbell.net [64.216.1.125]) by hub.org (8.10.1/8.10.1) with ESMTP id e7C2q5G41153 for ; Fri, 11 Aug 2000 22:52:06 -0400 (EDT) Received: from linux2 (IDENT:jmckown@linux2 [192.168.151.21]) by linux2.johnmckown.net (8.10.1/8.10.1) with ESMTP id e7C2t6h15409; Fri, 11 Aug 2000 21:55:06 -0500 Date: Fri, 11 Aug 2000 21:55:05 -0500 (CDT) From: John McKown X-Sender: jmckown@linux2.johnmckown.net To: David Lloyd-Jones cc: pgsql-sql@postgresql.org Subject: Re: Week of the Year? In-Reply-To: <001501c003fc$85ea9880$e5667bd8@WORKGROUP> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200008/83 Try using the function date_part such as: select date_part('week',now()); "and the days that are in that week" I guess want to answer a question such as: Given a date, what is first date in that same week, and what is the last date in that week. There are a couple of approaches to this. My first was: select to_date(date_part('year',now()),'YYYY')+(7*date_part('week',now())); and the above +6 to the the last day of the week. Another approach for this same question is much simplier (if the question is indeed what you are asking) select now()-date_part('dow',now()); This last select gives the Sunday for the current week. To get the Saturday, simply: select now()-date_part('dow',now())+6; Of course, replace the now() with whatever contains the date or timestamp. John McKown > I'm probably staring right at it. (One of the difficulties with RTFMing, is > having too many docs!) > > Is there anything in the API that produces the week of the year, from 1 to > 52 or 53 depending on the week of the year, and the days that are in that > week? > > Many thanks. > > -dlj. > > >