Hi
2015-12-26 8:28 GMT+01:00 Kevin Waterson <kevin.waterson@xxxxxxxxx>:
I wish to set up a table of recurring, and non-recurring events.I have been looking at http://justatheory.com/computers/databases/postgresql/recurring_events.htmlwhich looks nice (complex but nice) and wonder if there was a better option for this in more recent pgsql versions.All pointers gratefully received.
use generate_series
postgres=# select v::date from generate_series(current_date, current_date + 100, interval '7days') g(v);
┌────────────┐
│ v │
╞════════════╡
│ 2015-12-26 │
│ 2016-01-02 │
│ 2016-01-09 │
│ 2016-01-16 │
│ 2016-01-23 │
│ 2016-01-30 │
│ 2016-02-06 │
│ 2016-02-13 │
│ 2016-02-20 │
│ 2016-02-27 │
│ 2016-03-05 │
│ 2016-03-12 │
│ 2016-03-19 │
│ 2016-03-26 │
│ 2016-04-02 │
└────────────┘
(15 rows)
postgres=# select v::date from generate_series(current_date, current_date + 100, interval '7days') g(v);
┌────────────┐
│ v │
╞════════════╡
│ 2015-12-26 │
│ 2016-01-02 │
│ 2016-01-09 │
│ 2016-01-16 │
│ 2016-01-23 │
│ 2016-01-30 │
│ 2016-02-06 │
│ 2016-02-13 │
│ 2016-02-20 │
│ 2016-02-27 │
│ 2016-03-05 │
│ 2016-03-12 │
│ 2016-03-19 │
│ 2016-03-26 │
│ 2016-04-02 │
└────────────┘
(15 rows)
Kev