Results 1 to 3 of 3

Thread: minute and hour

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 1999
    Location
    San Diego, Ca , USA
    Posts
    44
    Hi,

    I am trying to get the difference if time and I am having problem, here is my code, any help is appretiated. Thanks in advance!

    Dim MyTime As Date
    Dim MyMinute As Date
    Dim m As Date
    Dim m2 As Date
    Dim h As Date

    MyTime = #6:35:17 PM# ' Assign a time.
    m = #5:30:17 PM# ' Assign a time.
    MyMinute = Minute(MyTime) ' MyMinute contains 35.
    If MyTime > m Then
    h = Hour(MyTime) - Hour(m)
    If h >= 0 Then
    m2 = Minute(MyTime) - Minute(m)
    h = m2 + h
    MsgBox h
    End If
    End If

  2. #2
    Hyperactive Member
    Join Date
    Jan 2000
    Location
    London
    Posts
    290
    I could be confusing you here, but one approach would be to convert both times into seconds, do the subtraction, then convert the result back into hhmmss.

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    How about using a simple function:

    DateDiff(interval, date1, date2)

    where interval can be set to:

    yyyy Year
    q Quarter
    m Month
    y Day of year
    d Day
    w Weekday
    ww Week
    h Hour
    n Minute
    s Second

    Hope you can use it

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