How do I find difference in times?

B

bgarey

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?
 
S

Sharkbyte

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
 
J

James A. Fortune

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
 
J

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
 
Top