Re: Help With date/time

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Alex <alex(at)meerkatsoft(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Help With date/time
Date: 2003-11-08 17:28:54
Message-ID: 20031108172854.GA22452@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sun, Nov 09, 2003 at 02:04:22 +0900,
Alex <alex(at)meerkatsoft(dot)com> wrote:
> Hi,
> I want to remove data that is older that a certain number of months..
> only full months.

One approach would be to get the year, month and day as numbers from
the current date. Then change the day to 1 and subtract 3 from the
month (borrowing 1 from the year if necessary) and then use these
numbers to build the date you want to test against.

>
> example: today is 11-08 and I want do delete all data that is older than
> this month - 3 month i.e. i want to delete all information that is older
> than Aug. 1st.
>
> Is there an easy way to do that ? Interval cannot be used and I cannot
> just pass something like now()::date < '2003-08'
>
> Thanks for any help here
> Alex
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jan Wieck 2003-11-08 17:35:49 Re: int8 primary keys still not using index without manual
Previous Message Alex 2003-11-08 17:04:22 Help With date/time