Results 1 to 3 of 3

Thread: [RESOLVED] calculations with Time

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2007
    Location
    cobwebbed to PC
    Posts
    311

    Resolved [RESOLVED] calculations with Time

    can calculations be performed with time?

    ie can I do at some point:

    Code:
    startTime = Time
    .
    .
    and then later on
    .
    .
    otherTime = Time
    totalTime = otherTime-startTime?
    or something like:

    Code:
    tenMinsAgo = Time - 00:10:00
    ???

    any help much appreciated
    Last edited by wolf99; Jun 13th, 2007 at 12:29 PM. Reason: add code tags

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: calculations with Time

    Here are a couple of examples if this is what you are looking for
    Code:
    Private Sub Command1_Click()
    Dim SubHours As Integer
    SubHours = CInt(Text1.Text)
    MsgBox DateAdd("h", -SubHours, Time)
    End Sub
    
    'or
    
    MsgBox DateDiff("h", #8:30:00 AM#, #12:30:00 PM#)

  3. #3
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: calculations with Time

    Subtraction works as long as its in the same day, if spanning occurs then http://www.vbforums.com/showthread.php?t=471664

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