Received: from home.mediaparks.lv (home.mediaparks.lv [195.2.123.220]) by hub.org (8.10.1/8.10.1) with ESMTP id e748dHG43073 for ; Fri, 4 Aug 2000 04:39:17 -0400 (EDT) Received: from sandis (sandis.mediaparks.lv [195.2.123.209]) by home.mediaparks.lv (8.9.3/8.9.3) with SMTP id KAA27718 for ; Fri, 4 Aug 2000 10:39:20 +0300 Message-ID: <000a01bffde7$4bb21d20$d17b02c3@mediaparks.lv> From: "Sandis" To: References: Subject: Re: Extracting data by months Date: Fri, 4 Aug 2000 10:40:43 +0300 MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1257" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-Archive-Number: 200008/36 I do it like this: SELECT datums FROM jaunumi WHERE date_part('year',datetime(datums)) = '2000' AND date_part('month',datetime(datums)) = '08'; Where datums is a timestamp field. Regards, Sandis Jerics www.mediaparks.lv > This might seem rather silly, but could you simply do something like: > > select * from database > where date_field >= '01/01/2000'::date > and date_field < '02/01/2000'::date; > > Of course, if date_field could contain many different years, then this > would not get you the result you wanted. > > John > > On Thu, 3 Aug 2000, Antti Linno wrote: > > > Lo. > > > > I'm in dire need of knowledge, how to extract data by month. Monthday > > and year arent' important, those I can't give from perl script, but what > > I do give to postgres are the numbers of the months. Date field is in > > timestamp. I thought about date_trunc, but I can't think of, how to get > > data with it. In script will be 12 queries, for each month, to get the > > news from that month. > > Btw, is there somewhere a manual about date_trunc, the docs that come with > > RH6.1 distribution are somewhat short and lacking explanation of > > date_trunc. > > Antti > > > > >