How do I find difference in times?

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

Guest

I have a list of times starting with zero in a table as shown below:
0 0:00:00
1 0:12:33
2 0:15:36
3 0:18:02
and so on.

I need to set up in a query or form, etc. a way to find the difference in
sequential times as shown below:

0 0:00:00
1 0:12:33 0:12:33
2 0:15:36 0:03:03
3 0:18:48 0:03:12

Any help?
 
To get the difference, you should be able to simply subtract the times. So
long as you are always dealing with the previous time, you can use the record
ID number and (ID-1) to identify which times to calculate.

Good luck.

Sharkbyte
 
bgarey said:
I have a list of times starting with zero in a table as shown below:
0 0:00:00
1 0:12:33
2 0:15:36
3 0:18:02
and so on.

I need to set up in a query or form, etc. a way to find the difference in
sequential times as shown below:

0 0:00:00
1 0:12:33 0:12:33
2 0:15:36 0:03:03
3 0:18:48 0:03:12

Any help?
Sharkbyte's idea should work. Alternatively, I tried this using a
string for TimeValue and found it interesting.

tblTimes
TimeID TimeNumber TimeValue (Text)
1 0 0:00:00
2 1 0:12:33
3 2 0:15:36
4 3 0:18:48

If the TimeNumber values all increase by 1 (else use TimeID) try:

qryTimes:
SELECT TimeNumber, TimeValue, (SELECT A.TimeValue FROM tblTimes AS A
WHERE A.TimeNumber = tblTimes.TimeNumber - 1) AS PrevTimeValue,
(Hour(TimeValue) - Hour(PrevTimeValue)) * 3600 + (Minute(TimeValue) -
Minute(PrevTimeValue)) * 60 + Second(TimeValue) - Second(PrevTimeValue)
AS ElapsedSeconds, ElapsedSeconds \ 3600 AS theHours, ElapsedSeconds \
60 - 60 * theHours AS theMinutes, ElapsedSeconds - 60 * theMinutes -
3600 * theHours AS theSeconds, IIf(IsNull(theHours), Null, theHours &
':' & Format(theMinutes, '00') & ':' & Format(theSeconds, '00')) AS
Difference FROM tblTimes;

!qryTimes:
TimeNumber ... Difference
0 Null
1 0:12:33
2 0:03:03
3 0:03:12

James A. Fortune
 
Aderorho said:
How do i set up and use Outlook Express?

Regards

Eery

I use Mozilla Thunderbird to post to this NG so I'm not familiar with
how to setup Outlook Express for reading this newsgroup. Sorry. Maybe
someone else can help you with the OE settings.

James A. Fortune
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top