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

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

pgsql-novice by date

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

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