DURETTE, STEVEN J (AIT) wrote:
>  
> BEGIN
>  
> declare @yourTable table(
>  EntryNo int,
>  startDateField datetime,
>  endDateField datetime
> )
>  
> insert into @yourTable(entryNo, startDateField, endDateField) values(1, '11-25-2003', '12-15-2003')
> insert into @yourTable(entryNo, startDateField, endDateField) values(2, '12-31-2003', '01-15-2004')
> insert into @yourTable(entryNo, startDateField, endDateField) values(3, '11-25-2003', '12-01-2003')
> insert into @yourTable(entryNo, startDateField, endDateField) values(4, '1-25-2004', '2-15-2004')
> insert into @yourTable(entryNo, startDateField, endDateField) values(5, '12-25-2003', '12-30-2003')
>  
> select *
> from @yourTable
> where startDateField < '12-31-2003'
> and endDateField > '12-01-2003'
>  
> delete from @yourTable
>  
> end
>  
> This worked but missed entries 2 and 3, mine picked them up immediately.

It is supposed to miss them. If a persons shift ends at X, why
shouldn't the next shift of that person be allowed to start at X
either?

> I will say this though, for Candace's problem your solution with the added =
> is probably better.

Even without the added =. Your solution still does not find any
that completely envelope other ranges. PostgreSQL shows:

jochemd=> BEGIN;
jochemd=> CREATE TABLE yourTable (
jochemd(> startDateField TIMESTAMP,
jochemd(> endDateField TIMESTAMP);
jochemd=> INSERT INTO yourTable
jochemd-> VALUES ('2003-11-25 00:00:00', '2004-12-15 23:59:59');
jochemd=>
jochemd=>
jochemd=> SELECT *
jochemd-> FROM   yourtable
jochemd-> WHERE  ((startDateField between '2003-12-01 00:00:00'
and '2003-12-31 23:59:59')
jochemd(>          OR
jochemd(>          (endDateField between '2003-12-01 00:00:00'
and '2003-12-31 23:59:59'));
  startdatefield | enddatefield
----------------+--------------
(0 rows)
jochemd=>
jochemd=> ROLLBACK;

Jochem

--
Who needs virtual reality
if you can just dream?
     - Loesje
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to