Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL to display available timeslots
Message
From
13/03/2000 22:53:59
Gavin Reid
L & M Marketing Pty Ltd
Frenchs Forest, Australia
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00345180
Message ID:
00345214
Views:
19
Hi Kirk,

Try this

SELECT ts.timeslotdesc ;
FROM ts, sc ;
WHERE BETWEEN(ts.timeslotdesc,sc.scheduledstart,sc.scheduledend);
GROUP BY timeslotdesc ;
INTO CURSOR ts1

SELECT * from ts ;
WHERE timeslotdesc ;
NOT IN ( SELECT timeslotdesc FROM ts1 ) ;
INTO CURSOR ts2

Regards,
Gavin...

>I have two tables. The first table TS (TimeSlots) has the column TimeSlotDesc defined as a datetime field. Right now there are 55 records that have valid time slots:
>
>03/15/2000 00:15:00
>03/15/2000 00:30:00
>03/15/2000 00:45:00
>...through
>03/15/2000 13:15:00
>
>These records reflects time slots that the user can choose, unless that slot is already reserved. The second table is SC (SlotsScheduled), and it contains a ScheduledStart (datetime) and ScheduledEnd (datetime). They are not linked. There are two records (early testing) that have the following scheduledstart and scheduledend:
>
>ScheduledStart ScheduledEnd
>03/15/2000 07:00:00 03/15/2000 07:45:00
>03/15/2000 08:00:00 03/15/2000 08:30:00
>
>What I'd like to return is a cursor that displays time slots
>that are not occupied by the SlotsTaken, i.e. not display the slots
>between 07:00-07:45 and 08:00-08:30
>
>Here is the SQL-Select i've tried, limiting the results to slots
>greater than 05:00
>
>select ttoc(ts.timeslotdesc,2) ;
> from ts,sc ;
> where !between(ttoc(timeslotdesc,2),ttoc(scheduledstart,2),ttoc(scheduledend,2));
> and ttoc(ts.timeslotdesc,2)> '05:00:00' ;
> order by timeslotdesc into cursor ts1
>
>Results: All records returned
>05:15-13:15
>
>If I delete the second record, I get what I want:
>05:15:00
>05:30:00
>05:45:00
>06:00:00
>06:15:00
>06:30:00
>06:45:00 && Leave the 07:00-07:45 Out
>08:00:00
>08:15:00
>08:30:00
>08:45:00
>
>Any help greatly appreciated.
>
>Kirk
Previous
Reply
Map
View

Click here to load this message in the networking platform