Feature Request: "generate_series(DATE, DATE)" and "generate_series(DATE, DATE, INT)" - Mailing list pgsql-hackers

From Tim Landscheidt
Subject Feature Request: "generate_series(DATE, DATE)" and "generate_series(DATE, DATE, INT)"
Date
Msg-id m3eip8nsg1.fsf@passepartout.tim-landscheidt.de
Whole thread Raw
List pgsql-hackers
Hi,

as discussed on -general, I'd like to propose that Post-
greSQL provides "generate_series(DATE, DATE)" and
"generate_series(DATE, DATE, INT)" functions by default.
 They are merely syntactic sugar for
"generate_series($1::TIMESTAMP, $2::TIMESTAMP[,
'$3 days'::INTERVAL])::DATE" and can be used whenever a
range of dates is used, e. g. to ("LEFT JOIN"ly) group rows
by calendar date.
 Non-C implementations would be (credits to Sam Mason):

| CREATE FUNCTION generate_series(DATE, DATE)
|    RETURNS SETOF DATE
|    IMMUTABLE LANGUAGE SQL AS
|    $$SELECT generate_series($1::TIMESTAMP, $2::TIMESTAMP, '1 day'::INTERVAL)::DATE;$$;
| CREATE FUNCTION generate_series(DATE, DATE, INT)
|    RETURNS SETOF DATE
|    IMMUTABLE LANGUAGE SQL AS
|    $$SELECT generate_series($1::TIMESTAMP, $2::TIMESTAMP, ($3 || ' days')::INTERVAL)::DATE;$$;

TIA,
Tim



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: GRANT ON ALL IN schema
Next
From: Itagaki Takahiro
Date:
Subject: Re: Encoding issues in console and eventlog on win32