Re: First day of month, last day of month

From: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
To: "Nacef LABIDI" <nacef(dot)l(at)gmail(dot)com>
Cc: "Colin Wetherbee" <cww(at)denterprises(dot)org>, "Frank Bax" <fbax(at)sympatico(dot)ca>, pgsql-sql(at)postgresql(dot)org
Subject: Re: First day of month, last day of month
Date: 2008-04-24 14:55:31
Message-ID: dcc563d10804240755w612ec586l6bf8b0f4a805d49f@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Thu, Apr 24, 2008 at 8:43 AM, Nacef LABIDI <nacef(dot)l(at)gmail(dot)com> 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';

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Scott Marlowe 2008-04-24 14:56:50 Re: First day of month, last day of month
Previous Message Terry Lee Tucker 2008-04-24 14:52:43 Re: First day of month, last day of month