Re: Date manipulation

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Hadley Willan <hadley(dot)willan(at)deeperdesign(dot)co(dot)nz>
Cc: 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 03:25:05
Message-ID: 14457.1082345105@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hadley Willan <hadley(dot)willan(at)deeperdesign(dot)co(dot)nz> writes:
> I take it I could just use ''now'' instead of a date
> dateRange = ''now''::date - ( 7 * '1 week'::interval );

You probably want to use the SQL-standard spelling:

dateRange = current_date - ( 7 * '1 week'::interval );

Aside from being standard, this doesn't pose risk of the constant being
reduced sooner than you want. The other way is likely to break if the
plpgsql function gets cached over more than a day.

regards, tom lane

In response to

Browse pgsql-general by date

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