Re: Average speed
Posted in 1999
Topics: General Discussion
Hi.. Thank you.. but I knew that one :o) The real problem I am facing, as you can see on the first message I posted, is to get a real value that tells me exactly how many hours a given time in interval format is. Fx. I have a interval hour to fraction(2) field that has a value of 0:30:00.00 and I need some way to calculate that to 0.5 -- because 30 minutes equal 0.5 hours. I need this real value to calculate the speed in format of km/h. Arnar ----- Original Message ----- From: Paul Crompton <PCrompton@CLERK-OF-COURT.co.lee.fl.us> To: 'Arnar Birgisson' <arnar@visir.is> Sent: Friday, August 20, 1999 12:58 PM Subject: RE: Average speed > Speed = distance / time > > > If you have multiple times then you get an average of the times prior to > performing the calculation. > This will give you the average. If you need more just ask and I can send > some examples. > > > > > ---------- > > From: Arnar Birgisson[SMTP:arnar@visir.is] > > Sent: Friday, August 20, 1999 6:27 AM > > To: informix-list@iiug.org > > Subject: Average speed > > > > Hi.. > > > > I posted message here earlier on calculating average speed when I have > > distance and the time it took to go that distance. Is it impossible to > > calculate the average speed? I find it hard to believe. My small amount of > > intelligence isn't capable of finding out how to do that, but so many > > smart > > people and still no way to perform that simple task? > > > > best regards, > > Arnar > > >
Arnar Birgisson wrote: > Thank you.. but I knew that one :o) > > The real problem I am facing, as you can see on the first message > I posted, is to get a real value that tells me exactly how many > hours a given time in interval format is. Fx. I have a interval hour > to fraction(2) field that has a value of 0:30:00.00 and I need some > way to calculate that to 0.5 -- because 30 minutes equal 0.5 hours. > I need this real value to calculate the speed in format of km/h. Now we get the real question -- I see no mention of converting intervals in your original question. You need to do: SELECT distance / ((interval(0.00) seconds(9) to fraction(2) + timeval) / 3600.0) FROM Whereever The LHS (left-hand side) of the addition determines the precision of the result, so the value of the addition is your time (eg 30 minutes) converted to 2 decimal places of seconds; the division by 3600 converts to hours; and as long as your distance is in kilometres, your answer will be in kilometres per hour. > ----- Original Message ----- > From: Paul Crompton <PCrompton@CLERK-OF-COURT.co.lee.fl.us> > Sent: Friday, August 20, 1999 12:58 PM > > > Speed = distance / time > > > > If you have multiple times then you get an average of the times > > prior to performing the calculation. This will give you the > > average. If you need more just ask and I can send some examples. > > > > > ---------- > > > From: Arnar Birgisson[SMTP:arnar@visir.is] > > > Sent: Friday, August 20, 1999 6:27 AM > > > > > > I posted message here earlier on calculating average speed when > > > I have distance and the time it took to go that distance. Is it > > > impossible to calculate the average speed? I find it hard to > > > believe. My small amount of intelligence isn't capable of finding > > > out how to do that, but so many smart people and still no way to > > > perform that simple task? -- Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net) Guardian of DBD::Informix v0.60 -- see http://www.perl.com/CPAN #include <disclaimer.h>