Format Of Time Difference

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

    #1

    Format Of Time Difference

    I'm trying to express the difference between two Date/Time fields as
    Hours:Minutes in the query grid by using:

    MoveTime: DateDiff("h",[MoveFrom],[MoveTo]) & ":" & (DateDiff("n",
    [MoveFrom],[MoveTo]) Mod 60)

    This almost works except a difference of 2 hours and 7 minutes
    displays as "2:7" instead of "2:07". Is there a way that I can force
    the query to display the required format?

    Any help is appreciated.

  • Allen Browne

    #2
    Re: Format Of Time Difference

    Try:
    MoveTime: DateDiff("h",[MoveFrom], [MoveTo]) &
    Format(DateDiff ("n", [MoveFrom], [MoveTo]) Mod 60, "\:00")

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

    "Wayne" <cqdigital@volc anomail.comwrot e in message
    news:1170747549 .596461.76080@l 53g2000cwa.goog legroups.com...
    I'm trying to express the difference between two Date/Time fields as
    Hours:Minutes in the query grid by using:
    >
    MoveTime: DateDiff("h",[MoveFrom],[MoveTo]) & ":" & (DateDiff("n",
    [MoveFrom],[MoveTo]) Mod 60)
    >
    This almost works except a difference of 2 hours and 7 minutes
    displays as "2:7" instead of "2:07". Is there a way that I can force
    the query to display the required format?
    >
    Any help is appreciated.

    Comment

    • Wayne

      #3
      Re: Format Of Time Difference

      Thanks Allen. It works perfectly.

      Comment

      Working...