Calculating Elapsed Minutes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bonehead

    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?

  • Jim Allensworth

    #2
    Re: Calculating Elapsed Minutes

    On Mon, 02 Feb 2004 16:19:23 -0800, bonehead <sendmenospam@h ere.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:35 PM#)
    65

    - Jim

    Comment

    • Allen Browne

      #3
      Re: Calculating Elapsed Minutes

      For an explanation of the issue involved, see:
      Calculating elapsed time
      at:
      How to calculate the difference between date/time values in a Microsoft Access database.


      --
      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@h ere.org> wrote in message
      news:401EE90B.8 080804@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]


      Comment

      • phobos

        #4
        Re: Calculating Elapsed Minutes

        "Jim Allensworth" <jimNOT@Notdata centricsolution s.com> wrote in message news:<401eee1b. 864045109@news. west.earthlink. net>...[color=blue]
        > On Mon, 02 Feb 2004 16:19:23 -0800, bonehead <sendmenospam@h ere.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:35 PM#)
        > 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'...

        Comment

        • bonehead

          #5
          Thanks 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.

          Comment

          Working...