Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-sql by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group