"sammy" <sammy1971@hotmail.com> wrote in message
news:OdtVFi0bGHA.1208@TK2MSFTNGP04.phx.gbl...
> Thanks for the response Uri,
> what I am thinking of best way to to describe the data is like this. I
> will create a table to hold sku's refering to the services to be booked
> the skutable should be something like this
> SKuID --PK
> Description --- char
> Durration -->30 minutes blocks number field where 1 = 30 and 2=60 and so
> on
> The employee table should be like this
> EmpID --->PK
> Fname
> Lname
> location
> ScheduleID -->FK
> the scheduletable should be like this
> SID --->PK
> sundayStart ---> ie 12/06/2006 9:30 AM
> SundayEnd ---> 12/06/2006 6:00 PM
> MondayStart
> MondayEnd
> TuesdayStart
> TuesdayEnd
> WedStart
> WedEnd
> ThurStart
> ThursEnd
> FridayStart
> FridayEnd
> SaturedayStart
> SatureDayEnd
>
> what I am trying to achieve can be described best as calenday with all
> employees, the workdays, starttime, endtime and the times they are
> available to take calls "calls are based on 30 minutes blocks incremening
> by 30 minutes.
> I hope that explains the issue better
>
> "Uri Dimant" <urid@iscar.co.il> wrote in message
> news:uij3ouzbGHA.536@TK2MSFTNGP02.phx.gbl...
>> sammy
>> It ishard to suggest soemthing without seeing the actual data and some
>> DDL
>> Take a look at Itzik Ben-Gan's example showing the intreval connections
>> to the internet and resturns the connections was made less than 5 minutes
>>
>> create table tblConnection
>> (
>> StartTimeCon datetime not null,
>> EndTimeCon datetime not null
>>
>> )
>>
>> insert into tblConnection(StartTimeCon,EndTimeCon)values ('20000610
>> 10:00','20000610 10:10')
>>
>> insert into tblConnection(StartTimeCon,EndTimeCon)values ('20000610
>> 10:20','20000610 10:22')
>> insert into tblConnection(StartTimeCon,EndTimeCon)values ('20000610
>> 10:23','20000610 10:25')
>> insert into tblConnection(StartTimeCon,EndTimeCon)values ('20000610
>> 10:27','20000610 10:45')
>>
>> insert into tblConnection(StartTimeCon,EndTimeCon)values ('20000610
>> 11:57','20000610 12:00')
>> insert into tblConnection(StartTimeCon,EndTimeCon)values ('20000610
>> 12:01','20000610 12:04')
>> insert into tblConnection(StartTimeCon,EndTimeCon)values ('20000610
>> 12:04','20000610 12:40')
>> select * from tblConnection
>>
>> SELECT
>> StartTimeCon,
>> ISNULL(
>> (SELECT MIN(EndTimeCon)
>> FROM tblConnection AS S3
>> WHERE S3.StartTimeCon >= S1.StartTimeCon
>> AND ISNULL(
>> DATEDIFF(
>> minute,
>> S3.EndTimeCon,
>> (SELECT MIN(StartTimeCon)
>> FROM tblConnection AS S4
>> WHERE S4.StartTimeCon > S3.EndTimeCon)), 5) >= 5),
>> EndTimeCon) AS EndTimeCon
>> FROM tblConnection AS S1
>> WHERE ISNULL(
>> DATEDIFF(
>> minute,
>> (SELECT MAX(EndTimeCon)
>> FROM tblConnection AS S2
>> WHERE S2.EndTimeCon < S1.StartTimeCon),S1.StartTimeCon),5) >= 5
>>
>>
>>
>>
>> "sammy" <sammy1971@hotmail.com> wrote in message
>> news:ejgXXazbGHA.4672@TK2MSFTNGP04.phx.gbl...
>>> Hey Guys,
>>> I am trying to create a web app that uses an SQL db to handle employee
>>> scheduling. I can design a table to hold the appointments with no
>>> problems but I need to be able to search for free time for the
>>> employees.
>>> all bookings are based on 30 minutes blocks.
>>> So far I managed to create all tables and this is what I have concerning
>>> the booking tables "after seeing this post on
>>>
http://www.webservertalk.com/archive289-2005-9-1206387.html due to my
>>> lack of DB design I am having a hard time understanding the solution.
>>>
>>> eventually I need to be able to achieve the search using similar
>>> statement to this
>>> select min(starttime)
>>> from schedule
>>> where usedflag='free'
>>> and duration >= :desired_duration
>>>
>>> but I am having a problem with tables structure.
>>> would someone explain the structure posted please?
>>> thanks in advance
>>>
>>>
>>>
>>
>>
>
>