Connecting Tech Pros Worldwide Forums | Help | Site Map

Calculating Elapsed Minutes

bonehead
Guest
 
Posts: n/a
#1: Nov 12 '05
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?


Jim Allensworth
Guest
 
Posts: n/a
#2: Nov 12 '05

re: Calculating Elapsed Minutes


On Mon, 02 Feb 2004 16:19:23 -0800, bonehead <sendmenospam@here.org>
wrote:
[color=blue]
>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?
>[/color]
Use DateDiff function:

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

- Jim
Allen Browne
Guest
 
Posts: n/a
#3: Nov 12 '05

re: Calculating Elapsed Minutes


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" <sendmenospam@here.org> wrote in message
news:401EE90B.8080804@here.org...[color=blue]
> 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?[/color]


phobos
Guest
 
Posts: n/a
#4: Nov 12 '05

re: Calculating Elapsed Minutes


"Jim Allensworth" <jimNOT@Notdatacentricsolutions.com> wrote in message news:<401eee1b.864045109@news.west.earthlink.net>. ..[color=blue]
> On Mon, 02 Feb 2004 16:19:23 -0800, bonehead <sendmenospam@here.org>
> wrote:
>[color=green]
> >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?
> >[/color]
> Use DateDiff function:
>
> ?DateDiff("n",#11:30AM#,#12:35PM#)
> 65
>
> - Jim[/color]

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'...
bonehead
Guest
 
Posts: n/a
#5: Nov 12 '05

re: Calculating Elapsed Minutes


Allen Browne wrote:[color=blue]
> For an explanation of the issue involved, see:
> Calculating elapsed time
> at:
> http://allenbrowne.com/casu-13.html[/color]

Ahh, very good. Thanks to all who responded.

Closed Thread


Similar Microsoft Access / VBA bytes