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