Subject Re: R: R: [ib-support] SUM( TIME FIELD ) Ann Harrison 2001-02-10T21:28:44Z
At 10:03 PM 2/10/2001 +0100, Arnaldo wrote:

> >
> > > > >I do:
> > > > >Select SUM( TIMEFIELD ), but cannot find a result.
> >
> > Time is different.
> >
> > 07:30 + 3 = 10:00
> >
> > A time plus a number produces a time. The "3" is
> > a number representing a duration of three hours.
> >
> > 12:00 - 8:00 = 4

This isn't right, in fact. The result of the subtraction
is the number of seconds between the two times. The
answer InterBase returns is 14400 (4 * 60 * 60)

>I have already done what You write, but with no success.
>I'll try another time, with more luck, I hope.

Here, let me give you an example:

create table timecard (
worker integer,
start_time time,
end_time time);

insert into timecard (worker, start_time, end_time)
values ('23', '08:00', '18:00');

select cast (((end_time - start_time) / 60 /60) as numeric (9,3)) as
hours_worked
from timecard
where worker = 23;

select sum (cast (((end_time - start_time) / 60 /60) as numeric (9,3))) as
hours_worked
from timecard
where worker = 23;

Ann
www.ibphoenix.com