Re: extract last months data

From: Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu>
To: Antti Linno <alligator(at)all(dot)ee>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: extract last months data
Date: 2000-06-28 14:12:34
Message-ID: 395A07D2.9947951F@alumni.caltech.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

> I just want to extract last months data, but I don't know whether the
> month ended with 29,30 or 31 (external program, that uses postgres),

select * from t1
where d >= (date_trunc('month', timestamp 'today')
- interval '1 month')
and d < date_trunc('month', timestamp 'today');

- Thomas

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Andrés Mauricio Marín Restrepo 2000-06-28 14:16:24 HI! Problems with cursors into triggers
Previous Message Guillaume Perréal 2000-06-28 11:35:03 Re: extract last months data