Received: from localhost (unknown [200.46.204.184]) by developer.postgresql.org (Postfix) with ESMTP id 413312E004B for ; Thu, 24 Apr 2008 11:55:42 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 72809-06 for ; Thu, 24 Apr 2008 11:55:25 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from wa-out-1112.google.com (wa-out-1112.google.com [209.85.146.178]) by developer.postgresql.org (Postfix) with ESMTP id 5CFAD2E0048 for ; Thu, 24 Apr 2008 11:55:34 -0300 (ADT) Received: by wa-out-1112.google.com with SMTP id n7so5448083wag.5 for ; Thu, 24 Apr 2008 07:55:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=icraxH/XAXM3rpOo5wgb8Fz3l31D+HDvsN0XzpaLfZc=; b=IEV8CCs8ldzKlRs5e6PSeHxeuxlruBwHvPxh1PtP6X/pK+B6G4bcdfZtDJdcWEh8zwvR/xnlxxUa9qXAPlRWFkAI6LjxTDndi9hvDVeutDdHYBuwVWFq+GaeThVv3ZSutV5cCDX6nLbHKABIhFRXo7ISy6TnqMk5LRL9Z6giqss= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=dpfce9cXQucpcxeFf3t33GfphE8+6mnl7CAJMNJHqDVsIC8yKNrpVKtWGWWlwGmbA+kDmXBnGPn36db3JvnNI7hcgrOnGiw0OBR/LjBbsGOI8NUMBPh1kE+6F512opP+9oMksGwPwB77t3+8pbsQzYLjmkWndRjNIoXapRiA2r0= Received: by 10.114.126.1 with SMTP id y1mr1867068wac.108.1209048932734; Thu, 24 Apr 2008 07:55:32 -0700 (PDT) Received: by 10.114.137.7 with HTTP; Thu, 24 Apr 2008 07:55:31 -0700 (PDT) Message-ID: Date: Thu, 24 Apr 2008 08:55:31 -0600 From: "Scott Marlowe" To: "Nacef LABIDI" Subject: Re: First day of month, last day of month Cc: "Colin Wetherbee" , "Frank Bax" , pgsql-sql@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <481085D1.2010807@sympatico.ca> <48108813.6070401@sympatico.ca> <481095FB.7090600@denterprises.org> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200804/162 X-Sequence-Number: 30701 On Thu, Apr 24, 2008 at 8:43 AM, Nacef LABIDI wrote: > Actually I want to select all rows whith dates between first day of the > month 00:00:00 and last date of the month 23:59:59 Then you can just use date_trunc on the values in the database. Plus if you're using timestamp WITHOUT timezone, you can index on it. create index table_datefield_month_trunc on table (date_trunc('month',datefield)); select * from table where date_trunc('month',timestampfield)='2007-10-01 00:00:00';