472,982 Members | 1,366 Online

# Calculating Elapsed Minutes

Greetings,

A friend tells me that he has not been able to work out an expression
that calculates elapsed minutes from TimeA to TimeB.

For example:

TIMEA TIMEB ELAPASED
----- ----- --------
11:30AM 12:35PM 65

Suggestions?

Nov 12 '05 #1
4 5544
On Mon, 02 Feb 2004 16:19:23 -0800, bonehead <se**********@here.org>
wrote:
Greetings,

A friend tells me that he has not been able to work out an expression
that calculates elapsed minutes from TimeA to TimeB.

For example:

TIMEA TIMEB ELAPASED
----- ----- --------
11:30AM 12:35PM 65

Suggestions?

Use DateDiff function:

?DateDiff("n",#11:30AM#,#12:35PM#)
65

- Jim
Nov 12 '05 #2
For an explanation of the issue involved, see:
Calculating elapsed time
at:
http://allenbrowne.com/casu-13.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

news:40**************@here.org...
Greetings,

A friend tells me that he has not been able to work out an expression
that calculates elapsed minutes from TimeA to TimeB.

For example:

TIMEA TIMEB ELAPASED
----- ----- --------
11:30AM 12:35PM 65

Suggestions?

Nov 12 '05 #3
"Jim Allensworth" <ji****@Notdatacentricsolutions.com> wrote in message news:<40****************@news.west.earthlink.net>. ..
On Mon, 02 Feb 2004 16:19:23 -0800, bonehead <se**********@here.org>
wrote:
Greetings,

A friend tells me that he has not been able to work out an expression
that calculates elapsed minutes from TimeA to TimeB.

For example:

TIMEA TIMEB ELAPASED
----- ----- --------
11:30AM 12:35PM 65

Suggestions?

Use DateDiff function:

?DateDiff("n",#11:30AM#,#12:35PM#)
65

- Jim

I have time data as four-digit numbers; would the regular time
functions work if I use string operations to glue # signs to the front
and back of them?

As it is, I use this:

Function TimeDiff(InTime, OutTime) As Integer
Dim InMSM As Integer
Dim OutMSM As Integer

'Handle nulls: this shouldn't arise
If IsNull(InTime) Then InTime = 0
If IsNull(OutTime) Then OutTime = 0

InMSM = 60 * Int(InTime / 100) + InTime Mod 100
OutMSM = 60 * Int(OutTime / 100) + OutTime Mod 100
TimeDiff = OutMSM - InMSM
End Function

This converts four-digit times into 'minutes since midnight' times.
Great for most purposes but it breaks if something overlaps midnight.
I suppose I could add clauses to the effect that 'if OutTime < InTime
then assume it's the next day'...
Nov 12 '05 #4
Allen Browne wrote:
For an explanation of the issue involved, see:
Calculating elapsed time
at:
http://allenbrowne.com/casu-13.html

Ahh, very good. Thanks to all who responded.

Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.