By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,928 Members | 1,210 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,928 IT Pros & Developers. It's quick & easy.

Calculating Elapsed Minutes

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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.

"bonehead" <se**********@here.org> wrote in message
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

P: n/a
"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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.