Subject | Revisiting: [firebird-support] time casting problem... |
---|---|
Author | Helen Borrie |
Post date | 2006-11-19T23:15:55Z |
Adam,
Sorry, after I hit the Send button I remembered you wanted a While
loop, I *think* because you actually want to increment the hours
count if the instructor had visits in a particular hour, i.e. you
don't care if there were multiple visits within an hour....
So, the modification is this:
create procedure XXXX (
StartDate Date,
EndDate Date,
StartTime Time,
EndTime Time,
idInstructor integer)
returns (
InstructorActivityHours integer,
.....)
as
begin
InstructorActivityHours = 0;
while (StartTime <= EndTime) DO
begin
if (exists (
select 1 from "Visit"
where
"idInstructor" = :idInstructor
and cast("Time" as Date) = :StartDate
and cast("Time" as Time) between :StartTime and :EndTime ) )
then
InstructorActivityHours = InstructorActivityHours + 1;
StartTime = StartTime + 3600; // increments StartTime by 1 hour
end
....
end
./heLen
Sorry, after I hit the Send button I remembered you wanted a While
loop, I *think* because you actually want to increment the hours
count if the instructor had visits in a particular hour, i.e. you
don't care if there were multiple visits within an hour....
So, the modification is this:
create procedure XXXX (
StartDate Date,
EndDate Date,
StartTime Time,
EndTime Time,
idInstructor integer)
returns (
InstructorActivityHours integer,
.....)
as
begin
InstructorActivityHours = 0;
while (StartTime <= EndTime) DO
begin
if (exists (
select 1 from "Visit"
where
"idInstructor" = :idInstructor
and cast("Time" as Date) = :StartDate
and cast("Time" as Time) between :StartTime and :EndTime ) )
then
InstructorActivityHours = InstructorActivityHours + 1;
StartTime = StartTime + 3600; // increments StartTime by 1 hour
end
....
end
./heLen