Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calculate time difference

Status
Not open for further replies.

vzachin

Technical User
Feb 10, 2006
305
US
hi,

i need to calculate the time difference in hours between two dates that also has the hours.

the data is formatted as follows:
02/04/10 15:00

Code:
    Dim Sessions, System As Object, Sess0 As Object,Sess As Object
    Set System = CreateObject("EXTRA.System")
    Set Sessions = System.Sessions
    Set Sess0 = System.ActiveSession
    Set Sess = Sess0.Screen 
begtime = trim(Sess.GetString (2,63,14))
endtime = trim(Sess.GetString (3,63,14))
[blue]timedif = endtime - begtime 'i'm getting a type mismatch. [/blue]
msgbox timedif

what am i missing?


thanks
zach







 



Hi,

Because you cannot do arithmetic on STRINGS.
Code:
begtime = trim(Sess.Get[red][b]String[/b][/red] (2,63,14))
endtime = trim(Sess.Get[red][b]String[/b][/red] (3,63,14))
You must CONVERT the string to a Date/Time value.
Code:
begtime = CVDate(Sess.GetString (2,63,8)) + TimeSerial(Sess.GetString (2,72,2),Sess.GetString (2,74,2),0)




Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
thanks skip for the info. i should have known better

zach
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top