473,405 Members | 2,415 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Calculate time (SUM)

Hi,

If someone could please please help me, it would be greatly appreciated

I am trying to calculate the time a vehicle has stopped in one place.

this is the query that shows where a vehicle has stopped..



Expand|Select|Wrap|Line Numbers
  1. SELECT
  2. `vehiclehistory`.`Vehicle`,
  3. `vehiclehistory`.`Date`,
  4. `vehiclehistory`.`Time`,
  5. `vehiclehistory`.`SpeedInst`,
  6. `vehiclehistory`.`Suburb`,
  7. `vehiclehistory`.`Street`,
  8. `vehiclehistory`.`Latitude`,
  9. `vehiclehistory`.`Longitude`,
  10. `vehiclehistory`.`SpeedMax`,
  11. `vehiclehistory`.`SpeedAv`,
  12. `vehiclehistory`.`CourseInst`,
  13. `vehiclehistory`.`CourseAv`
  14. FROM
  15. `vehiclehistory`
  16. WHERE
  17. `vehiclehistory`.`Vehicle` = "1008"
  18. AND
  19. `vehiclehistory`.`Date`= "2007-02-14"
  20. AND
  21. `vehiclehistory`.`SpeedInst` < "1"
  22. AND
  23. `vehiclehistory`.`CourseInst` = `vehiclehistory`.`CourseAv`
  24.  
  25. ORDER BY
  26. `vehiclehistory`.`Time` ASC
  27.  
This is a snippet of the data that comes out.



Expand|Select|Wrap|Line Numbers
  1. Vehicle Date Time SpeedInst Suburb Street Latitude Longitude SpeedMax SpeedAv CourseInst CourseAv
  2. 1008 14/2/2007 07:20:04 0 Punchbowl LUMEAH AV 33.56.187S 151.03.355E 0 0 0 0
  3. 1008 14/2/2007 07:22:34 0 Punchbowl ROSSMORE AV 33.55.930S 151.03.357E 0 0 305 305
  4. 1008 14/2/2007 07:25:36 0 Punchbowl ROSSMORE AV 33.55.930S 151.03.353E 0 0 305 305
  5. 1008 14/2/2007 07:28:38 0 Punchbowl ROSSMORE AV 33.55.931S 151.03.354E 0 0 305 305
  6. 1008 14/2/2007 07:46:50 0 Padstow VANNAN L 33.57.164S 151.01.798E 0 0 49 49
  7. 1008 14/2/2007 07:49:52 0 Padstow VANNAN L 33.57.164S 151.01.799E 0 0 49 49
  8. 1008 14/2/2007 07:52:54 0 Padstow VANNAN L 33.57.164S 151.01.799E 0 0 49 49
  9. 1008 14/2/2007 07:55:56 0 Padstow VANNAN L 33.57.164S 151.01.799E 0 0 49 49
  10. 1008 14/2/2007 07:58:58 0 Padstow VANNAN L 33.57.164S 151.01.799E 0 0 49 49
  11. 1008 14/2/2007 08:01:58 0 Padstow VANNAN L 33.57.164S 151.01.799E 0 0 49 49
  12. 1008 14/2/2007 08:04:14 0 Padstow VANNAN L 33.57.164S 151.01.799E 0 0 49 49
  13. 1008 14/2/2007 08:22:36 0 Revesby North FITZPATRICK ST 33.56.205S 151.00.175E 0 0 277 277
  14. 1008 14/2/2007 08:22:40 0 Revesby North FITZPATRICK ST 33.56.205S 151.00.175E 0 0 277 277
  15. 1008 14/2/2007 08:27:30 0 Revesby North FITZPATRICK ST 33.56.197S 151.00.149E 0 0 121 121
  16. 1008 14/2/2007 08:30:32 0 Revesby North FITZPATRICK ST 33.56.196S 151.00.149E 0 0 121 121
  17. 1008 14/2/2007 08:33:32 0 Revesby North FITZPATRICK ST 33.56.196S 151.00.150E 0 0 121 121
  18. 1008 14/2/2007 08:36:34 0 Revesby North FITZPATRICK ST 33.56.196S 151.00.150E 0 0 121 121
  19. 1008 14/2/2007 08:39:36 0 Revesby North FITZPATRICK ST 33.56.196S 151.00.150E 0 0 121 121
  20. 1008 14/2/2007 08:42:38 0 Revesby North FITZPATRICK ST 33.56.196S 151.00.149E 0 0 121 121
  21. 1008 14/2/2007 08:45:40 0 Revesby North FITZPATRICK ST 33.56.196S 151.00.149E 0 0 121 121
  22. 1008 14/2/2007 08:48:40 0 Revesby North FITZPATRICK ST 33.56.196S 151.00.149E 0 0 121 121
  23. 1008 14/2/2007 08:51:42 0 Revesby North FITZPATRICK ST 33.56.196S 151.00.149E 0 0 121 121
  24. 1008 14/2/2007 08:54:44 0 Revesby North FITZPATRICK ST 33.56.196S 151.00.149E 0 0 121 121
  25. 1008 14/2/2007 08:57:46 0 Revesby North FITZPATRICK ST 33.56.196S 151.00.149E 0 0 121 121
  26. 1008 14/2/2007 09:00:46 0 Revesby North FITZPATRICK ST 33.56.196S 151.00.149E 0 0 121 121
  27. 1008 14/2/2007 09:02:06 0 Revesby North FITZPATRICK ST 33.56.196S 151.00.149E 0 0 121 121
So what i am trying to do is group the stops together then get the total time the vehicle was stopped there.

So in Rossmore Ave, Punchbowl the vehicle was there from 07:22:34 to 07:28:38 = 6mins or so...

VANNAN L, Padstow 07:46:50 to 8:04:14 = 18 mins or so...

i hope this make sense....

Thank you in advance.
Feb 24 '07 #1
2 3837
Hi!

I have done it! ( I THINK....)

thank you for your help... timediff!!!!!

below is the query in case you or anyone who stumbles across the thread is interested..

Expand|Select|Wrap|Line Numbers
  1. SELECT
  2.  MIN(`vehiclehistory`.`Time`),
  3. MAX(`vehiclehistory`.`Time`) ,
  4.  
  5. timediff(MAX(`vehiclehistory`.`Time`) ,MIN(`vehiclehistory`.`Time`) ) as idle,
  6.  
  7. `vehiclehistory`.`Vehicle`,
  8. `vehiclehistory`.`Date`,
  9. `vehiclehistory`.`Time`,
  10. `vehiclehistory`.`SpeedInst`,
  11. `vehiclehistory`.`Suburb`,
  12. `vehiclehistory`.`Street`,
  13. `vehiclehistory`.`Latitude`,
  14. `vehiclehistory`.`Longitude`,
  15. `vehiclehistory`.`SpeedMax`,
  16. `vehiclehistory`.`SpeedAv`,
  17. `vehiclehistory`.`CourseInst`,
  18. `vehiclehistory`.`CourseAv`
  19. FROM
  20. `vehiclehistory` 
  21. WHERE 
  22. `vehiclehistory`.`Vehicle` = "1008"
  23. AND 
  24. `vehiclehistory`.`Date`= "2007-02-14"
  25. AND
  26. `vehiclehistory`.`SpeedInst` < "1"
  27. AND 
  28. `vehiclehistory`.`CourseInst` = `vehiclehistory`.`CourseAv`
  29.  
  30.  
  31. GROUP BY
  32. `vehiclehistory`.`CourseAv`
  33.  
  34. ORDER BY
  35. `vehiclehistory`.`Time` ASC
I know the group clause is incorrect.... will sort that out now...
Feb 25 '07 #2
ronverdonk
4,258 Expert 4TB
Glad you sorted that out by yourself. Good luck!

Ronald :cool:
Feb 26 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

28
by: Steve | last post by:
Hi all How would I find out the average date when given a bunch of dates? For example, I want to find the average length in time from the following dates:...
1
by: sg_s123 | last post by:
============================================================================ 02-Feb-04 03-Feb-04 Staff Staff 0800hr- 1300hr- 1700hr- 1900hr- 0800hr- 1300hr- 1700hr- 1900hr- Number...
1
by: Ladislau S. | last post by:
Dear reader, I am an occasional user of MS Access 2000 running on Windows 98. My hobby is ship model building so I made a database for things that I want to buy. After two strokes I bin unable...
3
by: | last post by:
Hello, I am hoping someone else has thought about a date time calculation i need to perform. I would like to be able to calculate the number of "working minutes" between 2 dates, given my...
5
by: kux | last post by:
Hello everyone, I hope someone is out here who can help me with a simple calculation... I have a sales data base in access with monthly sales history by product. to make future predictions I...
7
by: Jurek | last post by:
I have 10+ experience in C/C++ - mostly automation and graphics. I have never written any business apps though. Recently I've been asked to write a simple report that would calculate sales...
2
by: reidarT | last post by:
I have 3 fields in an aspx page. The 3. field should be the sum of field A and field B I use OnTextChanged to calculate the sum in field3. At the same time I want to insert the content of theese 3...
4
by: gaga | last post by:
hi guys, a part of my program requires me to calculate an average of items that are sold. the easiest way to do that would be writing a function, but im having trouble making up the parameters. if...
8
by: muddasirmunir | last post by:
how can we calculate data at run time in crystal report 10 i had made three fields in my database name debit,credit , balance debit and credit shows data directly from database now i want a...
0
by: SuzK | last post by:
I am trying to calculate in VBA in Access 2002 a moving average and update a table with the calculations. Fields in my WeeklyData table are Week Ending (date) ItemNbr (double) Sales Dollars...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.