Skip site navigation (1) Skip section navigation (2)

Re: Time Difference

From: Mike E <mee(at)quidquam(dot)com>
To: postgres mailinglist <pgsql-general(at)postgresql(dot)org>
Subject: Re: Time Difference
Date: 2000-10-27 12:39:05
Message-ID: 20001027053905.A35296@quidquam.com (view raw or flat)
Thread:
Lists: pgsql-general
On Fri, Oct 27, 2000 at 02:13:07PM +0200, Peter Pilsl wrote:
> On Fri, Oct 27, 2000 at 04:13:13AM -0700, Mike E wrote:
> > I have the following setup:
> > 
> > appt=# select * from availability \g
> >  emp_id |    date    | start_time | end_time 
> > --------+------------+------------+----------
> >       1 | 2000-10-30 | 08:00:00   | 14:30:00
> > 
> > appt=# select * from appointments \g
> >  start_time | end_time | emp_id | cus_id | services |    date    
> > ------------+----------+--------+--------+----------+------------
> >  09:00:00   | 11:30:00 |      1 |      2 | {1,2,3}  | 2000-10-30
> > 
> > Now, what I would like to get is the following:
> > 
> >  start_time | end_time 
> > ------------+----------
> >  08:00:00   | 09:00:00
> >  11:30:00   | 14:30:00
> >
> 
> not sure about the exact syntax, but to give you an idea:

That was just an example. What I would like to do is for any given
range of availabilty, take all the appointments, subtract/difference
them out and get a result set of all the time slots that are left.
Is this something that can be done in SQL, or will I have to pull
all the relevant data out and do all the logic in my application?

I will have a varying number of appointments on each day, which
possibly more than one availability record as well.

Thanks,

Mike

-- 
Mike Erickson <mee(at)quidquam> http://www.quidquam.com/
"Hatred is the coward's revenge for being intimidated" - George Bernard Shaw

In response to

pgsql-general by date

Next:From: Adam LangDate: 2000-10-27 12:53:31
Subject: Re: Postgres 7.0.2-2 on Red Hat 7.0?
Previous:From: Igor RoboulDate: 2000-10-27 12:23:08
Subject: Re: select and null

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group