Re: Checking for schedule conflicts - Mailing list pgsql-general

From Ragnar Hafstað
Subject Re: Checking for schedule conflicts
Date
Msg-id 1110622413.28805.13.camel@localhost.localdomain
Whole thread Raw
In response to Checking for schedule conflicts  (Benjamin Smith <lists@benjamindsmith.com>)
Responses Re: Checking for schedule conflicts  (Andre Maasikas <andre.maasikas@abs.ee>)
List pgsql-general
On Sat, 2005-03-12 at 00:13 -0800, Benjamin Smith wrote:
> Given the tables defined below, what's the easiest way to check for schedule
> conflicts?
>
> So far, the only way I've come up with is to create a huge, multi-dimensional
> array in PHP, with a data element for every minute of all time taken up by
> all events, and then check for any of these minutes to be set as I go through
> all the records. (ugh!)
>
> But, how could I do this in the database?
>
> But I'd like to see something like
> "select count(*) FROM events, sched
>  WHERE sched.date=$date
>  AND events.id=sched.events_id
>  ...
>  GROUP BY date, start<finish and finish<start
>  HAVING count(*) >1 "
>
> And here's where I get stumped. You can't group by start or end because we
> need to check if they OVERLAP any other records on the same date.
>
> Ideas?

use the OVERLAPS operator ?
http://www.postgresql.org/docs/8.0/interactive/functions-datetime.html

gnari



pgsql-general by date:

Previous
From: Ragnar Hafstað
Date:
Subject: Re: [JDBC] MS Access to PostgreSQL
Next
From: "Leif B. Kristensen"
Date:
Subject: Partial or incomplete dates