R
R
Rrooom2014-09-23 17:43:45
PostgreSQL
Rrooom, 2014-09-23 17:43:45

How to store schedule in Postgresql?

There are records in the database, they must be available according to date criteria - either within a certain period of time, for example - from 18:00 to 19:00, or only on Mondays and Tuesdays, or within a certain period of dates - for example, on New Year's holidays.
I can't figure out how to store them.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
mirror13, 2014-10-02
@Rrooom

To solve a similar problem, I took py-dateutil , it can expand a record of a set of dates (recurring events) from the iCalendar format (RFC2445), for example:

DTSTART:19970902T090000
RRULE:FREQ=DAILY;INTERVAL=10;COUNT=5

In base at me in the separate table Event this initial line and in the separate table the unrolled list of dates is stored. You can, of course, expand the string each time and not store the dates in the database, but I'm afraid that this option will be slower.

T
tgz, 2014-09-23
@tgz

So store it as a timestamp. And in requests already

... WHERE extract(hour from ts) BETWEEN 18 AND 19 ...;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question