8:00 am to 1:00 is 5 hours - how do I do that?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • buddyr
    New Member
    • Apr 2007
    • 105

    8:00 am to 1:00 is 5 hours - how do I do that?

    Hello,
    I have 3 textboxes
    Each textbox I have made a date/time value
    In the txtboxes I have format medium time
    I want to know how many hours passed from textbox1 to textbox2
    example:
    txtbox1 is 07:00am and txtbox2 is 03:00pm
    txtbox 3 - i want to show 8 hours
    tried using datediff
    not sure I have right data types
    thank you
  • missinglinq
    Recognized Expert Specialist
    • Nov 2006
    • 3533

    #2
    Date/Time datatype is correct. Use DateDiff() function:

    Me.Textbox3 = DateDiff("h",Te xtbox1, Textbox2)

    Linq ;0)>

    Comment

    • puppydogbuddy
      Recognized Expert Top Contributor
      • May 2007
      • 1923

      #3
      This link should answer most of your questions. If not, post back:

      How to calculate the difference between date/time values in a Microsoft Access database.



      To recap the link above, you would use the DateDiff function with the formula for Minutes placed as an alias name on the query grid of the query you are using as the record source for your form or report. The second formula should be placed in the control source of your third textbox. This formula will format the [Minutes] result from your query to hours and minutes for presentation purposes. Your first two textboxes will of course, contain the start and end dates/times, and should be formatted as general dates so that both the date and time components will be captured.

      Comment

      • buddyr
        New Member
        • Apr 2007
        • 105

        #4
        thank you
        but i am still getting a #Name? showing up in txtbox that should say the number of hours- what could that be?
        thanks

        Comment

        • buddyr
          New Member
          • Apr 2007
          • 105

          #5
          thanks puppydog
          I will look over that

          Comment

          • puppydogbuddy
            Recognized Expert Top Contributor
            • May 2007
            • 1923

            #6
            Originally posted by buddyr
            thank you
            but i am still getting a #Name? showing up in txtbox that should say the number of hours- what could that be?
            thanks
            You need to make sure your textboxes have the same name as the ones used in the link. It looks like you've named them textbox1 and textbox2. The link uses StartDateTime and EndDateTime.

            Comment

            Working...