Sorry for the late reply - is it still the weekend if I haven't slept since yesterday morning? :>

Jeremy Coulter wrote:
Hi All.
It must be the weekend or something, but I have 2 times I need to do a comparison on.
Basically I need to know this :-
Time_A=06:59:69
Time_B=16:00:00
TimeOf_event=00:05:00
Ok, now, if I go :- If (TimeOf_event<=Time_A) and (TimeOf_event>=Time_B) then
DoWhatEver;
Problem IS, this needs to return TRUE because the time of the event has to be within a time frame.
Infact, 16:00:00 is infact the START time of where the event must happen, and 06:59:59 is the FINISH time the event must happen before.
This is rolling over a day, so the above will never return TRUE.

Since 06:59:69 is numerically before 16:00:00, how about putting them into TDateTime objects with date values attached? That sorts out the problem of your 'end' being before your 'start'.


Of course if this is a daily event, then yeah, it's probably better to go with the 'or' solution. Logically speaking it's the same as:

  if not ((TimeOf_event > Time_A) and (TimeOf_event < Time_B))
    DoWhatever;

... which reads "If event time not between finish and start", and is a bit more self-explanatory... especially if you change the names of Time_A and Time_B, which are a little confusing in this context. How about StartTime and EndTime?

--
Corey Murtagh
The Electric Monk
"Quidquid latine dictum sit, altum viditur!"

---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to