http://www.linuxidc.com/Linux/2012-09/69670.htm
generate_series(start,stop) --int or bigint
generate_series(start,stop,step) --int or bigint
generate_series(start,stop, step interval) --timestamp or timestamp with time zone
SELECT generate_series(now(), now() + '10 day', '1 day')::DATE AS day;
2016-10-20
2016-10-21
2016-10-22
2016-10-23
2016-10-24
2016-10-25
2016-10-26
2016-10-27
2016-10-28
2016-10-29
2016-10-30
SELECT generate_series(1, 10, 2);
1
3
5
7
9
SELECT DATE (zz) FROM generate_series (date_trunc('day', to_date('20150305', 'yyyymm01') ), date_trunc('day', to_date('20150405', 'yyyymmdd') ), '1 day') AS tt (zz);
遍历当前月的各个天数
SELECT DATE (zz) as day FROM generate_series (date_trunc('day', to_date( to_char(now(), 'yyyymmdd'), 'yyyymm01') ), date_trunc('day', now() ), '1 day') AS tt (zz);