"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'...