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