From b6d15590f7269536c4da5b4cd835bc1e4f2cdf43 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 4 May 2008 23:19:24 +0000 Subject: Add timestamp and timestamptz versions of generate_series(). Hitoshi Harada --- doc/src/sgml/func.sgml | 48 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 10 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 47727a1f412..d168891d4e7 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -1,4 +1,4 @@ - + Functions and Operators @@ -10650,6 +10650,16 @@ AND + + generate_series(start, stop, step interval) + timestamp or timestamp with time zone + setof timestamp or setof timestamp with time zone (same as argument type) + + Generate a series of values, from start to stop + with a step size of step + + + @@ -10683,6 +10693,7 @@ select * from generate_series(4,3); ----------------- (0 rows) +-- this example relies on the date-plus-integer operator select current_date + s.a as dates from generate_series(0,14,7) as s(a); dates ------------ @@ -10690,16 +10701,26 @@ select current_date + s.a as dates from generate_series(0,14,7) as s(a); 2004-02-12 2004-02-19 (3 rows) + +select * from generate_series('2008-03-01 00:00'::timestamp, + '2008-03-04 12:00', '10 hours'); + generate_series +--------------------- + 2008-03-01 00:00:00 + 2008-03-01 10:00:00 + 2008-03-01 20:00:00 + 2008-03-02 06:00:00 + 2008-03-02 16:00:00 + 2008-03-03 02:00:00 + 2008-03-03 12:00:00 + 2008-03-03 22:00:00 + 2008-03-04 08:00:00 +(9 rows) - - - generate_subscripts - - - Subscripts Generating Functions + Subscript Generating Functions @@ -10711,7 +10732,7 @@ select current_date + s.a as dates from generate_series(0,14,7) as s(a); - generate_subscripts(array annyarray, dim int) + generate_subscripts(array anyarray, dim int) setof int Generate a series comprising the given array's subscripts. @@ -10719,7 +10740,7 @@ select current_date + s.a as dates from generate_series(0,14,7) as s(a); - generate_subscripts(array annyarray, dim int, reverse boolean) + generate_subscripts(array anyarray, dim int, reverse boolean) setof int Generate a series comprising the given array's subscripts. When @@ -10732,10 +10753,17 @@ select current_date + s.a as dates from generate_series(0,14,7) as s(a);
+ + generate_subscripts + + + generate_subscripts is a convenience function that generates + the set of valid subscripts for the specified dimension of the given + array. Zero rows are returned for arrays that do not have the requested dimension, or for NULL arrays (but valid subscripts are returned for NULL array - elements.) Some examples follow: + elements). Some examples follow: -- basic usage select generate_subscripts('{NULL,1,NULL,2}'::int[], 1) as s; -- cgit v1.2.3