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.

Soviut
  • 88,194
  • 49
  • 192
  • 260
terezzy
  • 243
  • 1
  • 3
  • 8

1 Answers1

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.

Soviut
  • 88,194
  • 49
  • 192
  • 260
filiprem
  • 6,721
  • 1
  • 29
  • 42
  • 2
    This one looks like it has a lot more functionality (rrule sets, which allow EXRULE as well): https://github.com/volkanunsal/postgres-rrule – DylanYoung Dec 20 '19 at 18:46