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

Thread: help!

  1. #1
    Guest

    help!

    Dear all,

    Many thanks for the recent posts on calculating time differences, but im still having problems with this.

    I have two fields inside a recordset which are type text, they have captured the time using the 'time' function. The field therefore looks something like this 3:09:31 PM.

    The fields are used for capturing login and logout times.
    First field 3:09:31 PM
    Second 3:15:16 PM

    Now i don't need to work out date differences, only times. But i obviously want to return something like 6 mins so many seconds, instead of xxxx seconds. Can someone pls point me in the right direction.

    Many thanks for all your help.


  2. #2
    Join Date
    Sep 1999
    Location
    Red Wing, MN USA
    Posts
    312

    Re: help!

    You coudl use the CDate Function to convert the Strings to Date/Time Variables, then Subtract One from the Other, eg.

    private Sub Command1_Click()
    Dim sTimeDiff as string
    sTimeDiff = Format(CDate("3:15:16 PM") - CDate("3:09:31 PM"), "NN:SS")
    End Sub



    In this case sTimeDiff Would Contain "05:45", (5 Mins, 45 Secs).

    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]
    Aaron Young
    Senior Programmer Analyst (Red Wing Software)
    Certified AllExperts Expert

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