Re: Date manipulation - Mailing list pgsql-general

From Tom Lane
Subject Re: Date manipulation
Date
Msg-id 14457.1082345105@sss.pgh.pa.us
Whole thread Raw
In response to Re: Date manipulation  (Hadley Willan <hadley.willan@deeperdesign.co.nz>)
List pgsql-general
Hadley Willan <hadley.willan@deeperdesign.co.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

pgsql-general by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: Date manipulation
Next
From: Tom Lane
Date:
Subject: Re: Date manipulation