Calculating Speed

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a project I'm working on that requires me to calculate the speed of a
vehicle. Currently I have a table that stores records with a vehicle
identifier, their beginning and ending time and odometer reading. At the end
of the vehicle's movement, I've calculated the distance and elapsed time but
I now need to create rate or speed...I assume the average...at which the
vehicle traveled throughout the event. I think I need to breakdown the
hours, minutes and seconds but formulating that into a sensible function is
where my problem is. Any suggestions?
 
Assuming your beginning and ending time fields are date/time data type, you
can use the DateDiff function to canculation the time interval between them:
DateDiff( "h", [StartTime], [EndTime] )
will give you the number of hours between the two times.

Unfortunately, the function returns only the number of whole, completed
units (in this case, hours) between the two times, so if you require any
degree of precision you should use a smaller unit ("n" = minutes, or "s" =
seconds) and divide appropriately. For example:
DateDiff( "n", [StartTime], [EndTime] ) / 60
or for even more precision:
DateDiff( "s", [StartTime], [EndTime] ) / 3600

Of course, the length of the journey is simply the difference between the
start and end odometer readings, so to calculate the average speed in
kilometres (or miles) per hour, you just divide the length of the journey by
the duration:
([EndOdo] - [StartOdo]) / (DateDiff( "s", [StartTime], [EndTime] ) /
3600)
 
Back
Top