Results 1 to 5 of 5

Thread: Adding

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2000
    Location
    Chesterfield, UK
    Posts
    298

    Adding

    If I have two values one = 8.45 (meaning 8 hours and 45 mins)
    and number two = 8.15

    My Answer will be 16.6 hours

    How do I get it to realise that it is not 16.6 hours but 17 hours??


    Regards


    Matt

  2. #2
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828
    don't use numbers to represent time.

    use date values.

    ie.

    VB Code:
    1. Private Sub Form_Load()
    2.     Dim dtmDate1 As Date
    3.     Dim dtmDate2 As Date
    4.    
    5.     dtmDate1 = #8:16:00 AM#
    6.     dtmDate2 = #9:00:00 AM#
    7.    
    8.     MsgBox "There are " & DateDiff("n", dtmDate1, dtmDate2) & " minutes difference."
    9. End Sub
    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

  3. #3
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828
    or in your case

    VB Code:
    1. Private Sub Form_Load()
    2.     Dim dtmNothing As Date
    3.     Dim dtmDate1 As Date
    4.     Dim dtmDate2 As Date
    5.     Dim dtmResult As Date
    6.    
    7.     dtmNothing = #12:00:00 AM#
    8.     dtmDate1 = #8:45:00 AM#
    9.     dtmDate2 = #8:15:00 AM#
    10.    
    11.     dtmResult = DateAdd("s", DateDiff("s", dtmNothing, dtmDate2), dtmDate1)
    12.    
    13.     MsgBox dtmResult
    14. End Sub

    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2000
    Location
    Chesterfield, UK
    Posts
    298

    Thanks

    Thankyou for your help once again,

    It works like a charm now!

    Thanks Again.

  5. #5
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828
    no problem
    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width