CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Time Diff

  1. #1
    Guest

    Time Diff

    Dear all,

    I have two times captured in a table using the 'time' command. I know how to work out the time in minutes, seconds, and hours....but i wanted to say return me the time difference in hours, minutes and seconds....without ending up with 1856 seconds difference.....i wanted say 2 mins 30 seconds....can anyone pls help.


  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: Time Diff

    Here is some VB 6 sample code to calculate the datetime difference between 2 dates.

    private Sub Command1_Click()
    Dim d1 as date
    Dim d2 as date
    d1 = #10/26/1999 12:00:00 PM#
    d2 = #11/15/1999 2:15:00 PM#
    Dim diff as date
    diff = d2 - d1
    MsgBox Day(diff) & " days " & Hour(diff) & " hours " & Minute(diff) & " minutes"
    End Sub





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

Featured