Re: generated dates from record dates - suggestions - Mailing list pgsql-sql

From Gary Stainburn
Subject Re: generated dates from record dates - suggestions
Date
Msg-id 201208221149.53634.gary.stainburn@ringways.co.uk
Whole thread Raw
In response to generated dates from record dates - suggestions  (Gary Stainburn <gary.stainburn@ringways.co.uk>)
List pgsql-sql
On Tuesday 21 August 2012 13:11:06 Johnny Winn wrote:
> CREATE OR REPLACE FUNCTION get_dates(date, date, date) RETURNS TABLE(date1
> date, date2 date)
> AS $$
> DECLARE
>   date_1 DATE := NULL;
>   date_2 DATE := NULL;
> BEGIN
>
>   -- test your conditions here
>
>   RETURN QUERY SELECT date_1::date, date_2::date;
> END;
> $$
> LANGUAGE PLPGSQL;
>
> I hope this helps,
> Johnny

Johnny,

Having gone down the CASE/WHEN route and found it too clumsy I'm now looking 
at using this method.  I'm just about to start writing the function, but I'm 
wondering how I would include this is the select / view .

Gary

-- 
Gary Stainburn
Group I.T. Manager
Ringways Garages
http://www.ringways.co.uk 



pgsql-sql by date:

Previous
From: Gary Stainburn
Date:
Subject: Re: generated dates from record dates - suggestions
Next
From: "Mubarik, Aiysha"
Date:
Subject: Tablesample Function on Postgres 9.1