Re: Date manipulation

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruno Wolff III <bruno(at)wolff(dot)to>
Cc: Hadley Willan <hadley(dot)willan(at)deeperdesign(dot)co(dot)nz>, Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>, PGSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Date manipulation
Date: 2004-04-19 04:42:58
Message-ID: 15231.1082349778@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Bruno Wolff III <bruno(at)wolff(dot)to> writes:
> Hadley Willan <hadley(dot)willan(at)deeperdesign(dot)co(dot)nz> wrote:
>> dateRange = ''now''::date - ( 7 * '1 week'::interval );

> If you actually are using a date you don't have to use an interval as
> the number subtracted will be in days. So you could just use
> current_date - (7 * 7);

Good point --- in fact, that's probably exactly what Hadley wants,
because "date - integer" will yield a date and not a timestamp. The
form involving interval will do odd things when crossing a DST
transition.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Hadley Willan 2004-04-19 05:42:21 Re: Date manipulation
Previous Message Bruno Wolff III 2004-04-19 03:27:48 Re: Date manipulation