Subject RE: [ib-support] How to multiply a time value and a numeric value and the final solution Cagatay Tengiz 2001-10-04T06:19:35Z
Hi ,

First of all thanks to everyone who tried to help me.

Second when I wrote that msg, it was about 11 pm and I was very tired and
the result is my english in the msg, sorry for that but you've managed to
understand what I was trying to ask. :)

Conclusion :
Yes in fact in my table I got start time and finish time. And in
update/insert triggers of my table I use a stored procedure to calculate the
working duration, but stored procedure also returns result value in time
type because I want to display the value in time format to the user. I am
giving the procedure here :

ALTER PROCEDURE FON_SUREBUL( BAS TIME, BIT TIME )
//"bas" means starting time and "bit" means ending time
RETURNS ( SURE TIME )
AS
declare variable ststr varchar(2);
declare variable dkstr varchar(2);
declare variable sat double precision;
declare variable zaman double precision;
declare variable ondalik double precision;
BEGIN
zaman = bit - bas;
sat = zaman/3600;

ondalik = sat - cast(sat as integer);
if (ondalik < 0) then ondalik = 1 + ondalik;
sat = sat - ondalik;

ststr = cast(cast(sat as integer) as varchar(2));
zaman = :zaman - (:sat * 3600);
dkstr = cast(cast(zaman/60 as integer) as varchar(2));
sure = ststr || ':' || dkstr;
suspend;
END

and finally I use triggers to calculate the cost of the work like this :
ALTER TRIGGER SURE_YAZ_INS
BEFORE INSERT
POSITION 0
AS
declare variable tutar double precision;
BEGIN
execute procedure fon_surebul(new.bassaat, new.bitsaat) returning_values
new.sure;
select maliyet from personel where kod = new.kod_per into :tutar;
new.maliyet = :tutar * (new.bitsaat - new.bassaat) / 3600 * 2.00;
//thanks to hans@...
END

and these solved my problem.

best regards

Cagatay Tengiz

-----Original Message-----
From: Helen Borrie [mailto:helebor@...]
Sent: Thursday, October 04, 2001 4:15 AM
To: ib-support@yahoogroups.com
Subject: Re: [ib-support] How to multiply a time value and a numeric
value.

At 10:49 PM 03-10-01 +0300, Catagay Tengiz wrote:
>Hi to all,
>
>In my table I'm trying to calculate the cost of a person by multiplying
>person's hour rate by working time.
>
>So I got a hourly rate value a numeric field and working time a time
field.
>
>When I try to multiply these I get an error.

You need a start time and a finish time.
Subtract start time from finish time to get duration in days
Multiply that result by 24 to get duration in hours.
Multiply that result by the hourly rate to get the cost.

TIME is confusing for non-native-English speakers! In English we say
"what is the time?" whereas other in other languages you say "what is the
hour?" The answer to this question is a TIME value.

But in English we also want to know the "time it took to do something".
This means a period of duration, interval, etc., and it is not a TIME value
but a double.

hth
Helen

To unsubscribe from this group, send an email to:
ib-support-unsubscribe@egroups.com