Subject | Re: Query using a range in where/having clause? |
---|---|
Author | kfkong |
Post date | 2004-06-08T02:00:37Z |
--- In firebird-support@yahoogroups.com, Daniel Rail <daniel@a...>
wrote:
Why make life so difficult? I assume that your UserStart/UserEnd are
all date variable. All you need to do is to do at your where clause
you put in ScheduleEnd <= UserStart and ScheduleEnd >= UserStart.
This should retrieve all the data you need.
However one more question, in your example above is your data type
for ScheduleStart/ScheduleEnd a date or Time or Timestamp? I am
actually confuse.... If according to your example above you are
better use timestamp, it should give you a more flexible search.
Peter
wrote:
> Hi,of now, I
>
> At June 6, 2004, 11:29, Lee Jenkins wrote:
>
> > I have a table thus:
>
> > CREATE TABLE SCHEDULE (
> > SERVERID INTEGER,
> > SCHEDULESTART DATE,
> > SCHEDULEEND DATE,
> > SCHEDULECLOSE BLANKSMALLINT,
> > SCHEDULEDATE DATE,
> > SCHEDULEID INTEGER NOT NULL,
> > STORENUMBER BLANKINTEGER,
> > TSTAMP DEFAULTNOW,
> > POSITIONID BLANKINTEGER,
> > SCHEDULER_ID BLANKINTEGER,
> > RATE DEFAULTNUMERIC,
> > TOTALHOURS BLANKDOUBLE
> > );
>
> > In my Delphi app, I have a grid
> > (http://65.39.139.136/images/scheduler.jpg)
> > that shows blocks of scheduled time in a color coded manor. As
> > have to do much processing on the client side to determine howto show the
> > "time blocks" in the app. What I would like to do is have aselectable SP
> > that I feed as parameters the starting and ending times the userwould like
> > to see and have that SP return the desired records.record should be
>
> > For instance, if there was a record:
>
> > ScheduleStart = 10:00:00 AM
> > ScheduleEnd = 4:00:00 PM
>
> > and the user indicated 12:00:00 PM to 3:00:00 PM, the above
> > chosen because it falls into the range of time selected by theuser.
>I couldn't
> > I hope this makes sense, but it was a late night last night and
> > sleep in today :)Daniel,
>
> Here's how I usually write my WHERE clauses for scheduling:
>
> ((ScheduleStart < UserStart) and (ScheduleEnd > UserEnd))
> OR (ScheduleStart BETWEEN UserStart and UserEnd)
> OR (ScheduleEnd BETWEEN UserStart and UserEnd)
>
> Hope this helps.
>
> --
> Best regards,
> Daniel Rail
> Senior System Engineer
> ACCRA Group Inc. (www.accra.ca)
> ACCRA Med Software Inc. (www.filopto.com)
Why make life so difficult? I assume that your UserStart/UserEnd are
all date variable. All you need to do is to do at your where clause
you put in ScheduleEnd <= UserStart and ScheduleEnd >= UserStart.
This should retrieve all the data you need.
However one more question, in your example above is your data type
for ScheduleStart/ScheduleEnd a date or Time or Timestamp? I am
actually confuse.... If according to your example above you are
better use timestamp, it should give you a more flexible search.
Peter