Results 1 to 6 of 6

Thread: Time Duration formatting

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2005
    Location
    Lahore
    Posts
    214

    Arrow Time Duration formatting

    Hi Everyone , have a great day , take look at line below which is infact VB6 code

    VB Code:
    1. duration = Format(CDate(Right(strline(UBound(strline)), Len(strline(UBound(strline))) - 12)) - CDate(Right(strline(0), Len(strline(0)) - 12)), "HH:MM:SS")

    Problem is that whenever value of duration exceeds 24 ( one complete day ) it sorta skips 24 , like

    in actual scenario value of duration is 31:06 , but it only shows 07:06 , what should i do ? since its VB6 code so i dont know any other format besides " HH:MM:SS" , which i have already given
    Regards

  2. #2
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: Time Duration formatting

    What is the Values of the Arrary strline?
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2005
    Location
    Lahore
    Posts
    214

    Re: Time Duration formatting

    _________________________________________________________________
    Event Time: 2006-05-01 12:01:00

    Problem Text:
    *** ALARM 174 A1/EXT "BSC01 R11/ACA3/"U 060501 1201
    RADIO X-CEIVER ADMINISTRATION
    BTS EXTERNAL FAULT

    MO RSITE CLASS
    RXOCF-131 MDLH1199 1

    EXTERNAL ALARM
    GENSET IN OPERATION

    END


    Problem Data:
    PRCA=53

    Clear Time: 2006-05-01 12:03:00

    _________________________________________________________________

    Thanks for reply mate
    Above given block is in that array and i m trying to get duration between event time and clear time ....
    Regards
    Waiting

  4. #4
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: Time Duration formatting

    How about this:


    VB Code:
    1. Option Explicit
    2.  
    3. Private Function GetTime(strline As String) As String
    4. Dim dtEventDateTime As Date
    5. Dim dtClearDateTime As Date
    6.  
    7.     dtEventDateTime = CDate(Mid(strline, InStr(strline, "Event Time: ") + 12, 19))
    8.     dtClearDateTime = CDate(Mid(strline, InStr(strline, "Clear Time: ") + 12, 19))
    9.    
    10.     GetTime = DateDiff("n", dtEventDateTime, dtClearDateTime) & _
    11.                          " minutes Difference Between Event Time and Clear Time"
    12. End Function
    13.  
    14. Private Sub Command1_Click()
    15. Dim strline As String
    16.  
    17.     Debug.Print GetTime(strline)
    18.  
    19. End Sub
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2005
    Location
    Lahore
    Posts
    214

    Re: Time Duration formatting

    Didn work
    "by ref argument type mismatch"

    isnt there some other way , i m really frustrated about this "lil " issue
    Regards

  6. #6
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: Time Duration formatting

    Quote Originally Posted by Dastard
    Didn work
    "by ref argument type mismatch"

    isnt there some other way , i m really frustrated about this "lil " issue
    Regards
    What type of variable is "strline"?
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


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