Hello all!
I am trying to create a TimeIt function...however, I am running into one trouble area. I have the following script; however, when the clock reaches past Midnight, the timing goes all wrong - I can't for the life of me figure out what I am doing wrong here.
-----------------------------------------------------
Log file output:
-----------------------------------------------------
7/23/2008 23:50:21: IE Browser was started.
It has been 19.03 hours since script was started.
7/23/2008 23:50:21: Firefox Browser was started.
It has been 19.03 hours since script was started.
7/24/2008 00:05:22: IE Browser was started.
It has been -17007 seconds since script was started.
7/24/2008 00:05:22: Firefox Browser was started.
It has been -17007 seconds since script was started.
-----------------------------------------------------
TimeIt Script
-----------------------------------------------------
Function TimeIt(strTime)
Dim strTime1, strTime2
'Store current time
strTime1 = Time
'Find time difference in seconds from when script started
'to when this function is being called - then store in
'variable.
strTime2 = DateDiff("s",strTime,strTime1)
'Test for string value then LogIt based off the
'amount of time that has passed.
If strTime2 < 60 Then
'Round to two decimal places.
strTime2 = Round(strTime2,2)
'Log to file function
LogIt(" It has been " & strTime2 & " seconds since script was started.")
Else If strTime2 = 60 Or strTime2 > 60 And strTime2 < 3600 Then
strTime2 = strTime2/60
strTime2 = Round(strTime2,2)
LogIt(" It has been " & strTime2 & " minutes since script was started.")
Else If strTime2 = 3600 Or strTime2 > 3600 And strTime2 < 86400 Then
strTime2 = strTime2/3600
strTime2 = Round(strTime2,2)
LogIt(" It has been " & strTime2 & " hours since script was started.")
Else If strTime2 > 86400 Then
strTime2 = strTime2/86400
strTime2 = Round(strTime2,2)
LogIt(" It has been " & strTime2 & " days since script was started.")
End If
End If
End If
End If
'clean memory
Set strTime1 = Nothing
Set strTime2 = Nothing
End Function
I am trying to create a TimeIt function...however, I am running into one trouble area. I have the following script; however, when the clock reaches past Midnight, the timing goes all wrong - I can't for the life of me figure out what I am doing wrong here.
-----------------------------------------------------
Log file output:
-----------------------------------------------------
7/23/2008 23:50:21: IE Browser was started.
It has been 19.03 hours since script was started.
7/23/2008 23:50:21: Firefox Browser was started.
It has been 19.03 hours since script was started.
7/24/2008 00:05:22: IE Browser was started.
It has been -17007 seconds since script was started.
7/24/2008 00:05:22: Firefox Browser was started.
It has been -17007 seconds since script was started.
-----------------------------------------------------
TimeIt Script
-----------------------------------------------------
Function TimeIt(strTime)
Dim strTime1, strTime2
'Store current time
strTime1 = Time
'Find time difference in seconds from when script started
'to when this function is being called - then store in
'variable.
strTime2 = DateDiff("s",strTime,strTime1)
'Test for string value then LogIt based off the
'amount of time that has passed.
If strTime2 < 60 Then
'Round to two decimal places.
strTime2 = Round(strTime2,2)
'Log to file function
LogIt(" It has been " & strTime2 & " seconds since script was started.")
Else If strTime2 = 60 Or strTime2 > 60 And strTime2 < 3600 Then
strTime2 = strTime2/60
strTime2 = Round(strTime2,2)
LogIt(" It has been " & strTime2 & " minutes since script was started.")
Else If strTime2 = 3600 Or strTime2 > 3600 And strTime2 < 86400 Then
strTime2 = strTime2/3600
strTime2 = Round(strTime2,2)
LogIt(" It has been " & strTime2 & " hours since script was started.")
Else If strTime2 > 86400 Then
strTime2 = strTime2/86400
strTime2 = Round(strTime2,2)
LogIt(" It has been " & strTime2 & " days since script was started.")
End If
End If
End If
End If
'clean memory
Set strTime1 = Nothing
Set strTime2 = Nothing
End Function