time differences 
Author Message
 time differences

have a database with two of the fields being date/time data type.  the
vb (16bit) form that displays the info from the table needs to show
timeA and timeB in two separate text boxes.  no problem there.  but must
have a third text box displaying timeC as the difference between times
A and B.  tried datediff and serial time with no luck.  any suggestions
for this newbie would be greatly appreciated.  tks in advance.


--
______________________________________________________________________________
     Bare your soles...
______________________________________________________________________________



Mon, 22 Feb 1999 03:00:00 GMT
 time differences

Quote:

>  have a database with two of the fields being date/time data type.  the
>  vb (16bit) form that displays the info from the table needs to show
>  timeA and timeB in two separate text boxes.  no problem there.  but must
>  have a third text box displaying timeC as the difference between times
>  A and B.  tried datediff and serial time with no luck.  any suggestions
>  for this newbie would be greatly appreciated.  tks in advance.

Have you tried something like: TimeC=format$(TimeB-TimeA,"hh:mm:ss")

Robert Chafer
Digital iD Picture Systems



Tue, 23 Feb 1999 03:00:00 GMT
 time differences

Quote:

> have a database with two of the fields being date/time data type.  the
> vb (16bit) form that displays the info from the table needs to show
> timeA and timeB in two separate text boxes.  no problem there.  but must
> have a third text box displaying timeC as the difference between times
> A and B.  tried datediff and serial time with no luck.  any suggestions
> for this newbie would be greatly appreciated.  tks in advance.

TimeC = DateDiff("n",TimeA,TimeB)

should return the difference between the two times in minutes.  You
could then use the MOD function to parse out days, hours, and remainder
minutes to display Time3 as you wish.  Check out the on-line Help in VB
for the DateDiff interval argument constants, if your concern is with
hours, days, months....

Alternatively, you could create a small user defined function in your
backend to do this.  If your db is Access and your db resides on a
faster box, then try this one:

Function GetTimeElapsed (interval)
    Dim ttlHours As Long
    Dim ttlMins As Long
    Dim ttlSecs As Long
    Dim Days As Long
    Dim Hours As Long
    Dim Mins As Long
    Dim Secs As Long

    Days = Int(CSng(interval))
    ttlHours = Int(CSng(interval * 24))
    ttlMins = Int(CSng(interval * 1440))
    ttlSecs = Int(CSng(interval * 86400))
    Hours = ttlHours Mod 24
    Hours = Hours + (Days * 24)
    Mins = ttlMins Mod 60
    Secs = ttlSecs Mod 60

    '   the returned value is:
    GetTimeElapsed = Hours & ":" & Format(Mins, "00")

End Function

Good luck, Dan

--
****************************************************************

*    w) 212-735-3000 x5645           cis: 76116,3227           *
*    h) 212-864-7273                                           *
*    f) 212-735-2001                                           *
****************************************************************



Tue, 23 Feb 1999 03:00:00 GMT
 
 [ 3 post ] 

 Relevant Pages 

1. selecting parts of a string, and calculating time differences

2. Row and Page locking - time difference

3. Time Difference

4. Extreme time differences btw MSSQL7 and MSSQL2000

5. When I use * in my SELECT the execution time difference is dramatic

6. time difference

7. time difference in milliseconds

8. Extreme time differences btw. MSQL7 and MSQL2000

9. Significant time difference in table loads via scripts

10. Current Time Difference

11. How to determine time difference in view


 
Powered by phpBB® Forum Software