Re: Previous month function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Aleksander Kmetec <aleksander(dot)kmetec(at)intera(dot)si>
Cc: mbaluyos(at)sni(dot)ph, pgsql-novice(at)postgresql(dot)org
Subject: Re: Previous month function
Date: 2004-11-17 15:27:21
Message-ID: 11614.1100705241@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Aleksander Kmetec <aleksander(dot)kmetec(at)intera(dot)si> writes:
> You can do something like this:

> test=> select NOW() - '1 month'::interval;
> ?column?
> -------------------------------
> 2004-10-17 12:31:09.944818+02

Also, depending on just what you meant by "previous month", you might
want to apply date_trunc():

regression=# select date_trunc('month', NOW()) - '1 month'::interval;
?column?
------------------------
2004-10-01 00:00:00-04
(1 row)

regards, tom lane

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message sarlav kumar 2004-11-17 16:50:20 subscribe for a digest fails
Previous Message Vishal Kashyap @ [SaiHertz] 2004-11-17 15:21:19 Re: upgrade from postgres 7.3.2