How to query recurrence rules in PostgreSQL?
Asked Answered
T

1

12

I have a recurrence table that stores the iCalendar RFC 5545 Recurrence Rule string. Ex:

FREQ=MONTHLY;INTERVAL=2

Does anyone know of any postgres functions similar to do the following?

get_events_between(date,date)

Where It would just query the recurrence table and parse the rrule string.

Thalamencephalon answered 27/8, 2015 at 20:35 Comment(1)
Hello @terezzy, do you have some news about this?Grenada
L
9

In PostgreSQL, as of version 14, there is no built-in support for RFC-5545 Recurrence Rule format.

But there are some custom extensions out there.

  1. pg_rrule. When you install it, you should be able to query Ical schedules this way:
SELECT *
FROM unnest(
    get_occurrences(
        'FREQ=MONTHLY;INTERVAL=2'::rrule,
        now(),
        now() + '6 months'::interval
    )
);
  1. postgres-rrule

  2. You can get a Python RRULE parser (like dateutil) and embed it postgres using PL/Python.

Lowrance answered 2/12, 2018 at 9:35 Comment(1)
This one looks like it has a lot more functionality (rrule sets, which allow EXRULE as well): github.com/volkanunsal/postgres-rruleIneffectual

© 2022 - 2024 — McMap. All rights reserved.