From: | Kevin Waterson <kevin(dot)waterson(at)gmail(dot)com> |
---|---|
To: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
Cc: | "pgsql-general(at)postgresql(dot)org >> PG-General Mailing List" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Recurring and non recurring events. |
Date: | 2015-12-26 12:03:30 |
Message-ID: | CAJSapQ1d--43T7Z9E45z7cmWLVfs1WogoPFZPt8DvFmttT3RuQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Thanks, as I am new to postgres, I was unaware of this function.
To go with this, I guess I will need a table with which to store intervals,
start and end dates?
eg
CREATE table events(
id serial primary key,
start_timestamp timestamp,
end_timestamp timestamp,
interval
with dateRange as
(
SELECT min(start_timestamp) as first_date, max(start_timestamp) as
last_date
FROM events
)
select
generate_series(first_date, last_date, '1 hour'::interval)::timestamp
as date_hour
from dateRange;
or something??
Kind regards
Kevin
On Sat, Dec 26, 2015 at 7:22 PM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
wrote:
> Hi
>
> 2015-12-26 8:28 GMT+01:00 Kevin Waterson <kevin(dot)waterson(at)gmail(dot)com>:
>
>> 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.html
>> which 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)
>
>
>> Kev
>>
>
>
--
--
"Democracy is two wolves and a lamb voting on what to have for lunch.
Liberty is a well-armed lamb contesting the vote."
From | Date | Subject | |
---|---|---|---|
Next Message | Sébastien Boutté | 2015-12-26 16:16:10 | Postgres Ubuntu Default Package vs Enterprise DB vs Compiled One |
Previous Message | Craig Ringer | 2015-12-26 11:56:37 | Re: BDR and synchronous replication |