Hopefully this will help until such time as there is a builtin function to do this type of conversion. The below is a complete working script, so you can either try it out or just copy & paste the subroutine part into your own script.
#SingleInstance
TimeStart = 20040401
TimeFinish = 20040405013150
; Measure the difference in seconds:
ConvertSeconds = %TimeFinish%
ConvertSeconds = %TimeStart%, seconds
Gosub, GetConvertResult
MsgBox, %ConvertSeconds% seconds is equivalent to %ConvertResult%
Exit
GetConvertResult:
; This subroutine takes the variable ConvertSeconds (set by the caller)
; and stores the converted time in the variable ConvertResult.
; Make a copy so that the caller's ConvertSeconds variable is not modified:
GCRTemp = %ConvertSeconds%
; Make floating point math more precise so that seconds are more accurate
; (this prevents it from being off by 1 second sometimes):
SetFormat, float, 0.20
; Convert to days by dividing by the number of seconds in a day.
GCRTemp /= 86400.0
; Truncate the decimal portion, leaving only the whole number of days in CountDays:
StringGetPos, DecimalPos, GCRTemp, .
StringLeft, CountDays, GCRTemp, %DecimalPos%
GCRTemp = %CountDays%
; Now GCRTemp contains something like 0.513, which is the number of
; "partial days" remaining that aren't yet reflected in CountDays.
GCRTemp *= 24 ; Now GCRTemp contains the number of remaining hours.
; Truncate the decimal portion, leaving only the whole number of hours in CountHours:
StringGetPos, DecimalPos, GCRTemp, .
StringLeft, CountHours, GCRTemp, %DecimalPos%
GCRTemp = %CountHours%
; Now GCRTemp contains something like 0.513, which is the number of
; "partial hours" remaining that aren't yet reflected in CountHours.
GCRTemp *= 60 ; Now GCRTemp contains the number of remaining minutes.
; Truncate the decimal portion, leaving only the whole number of minutes in CountMinutes:
StringGetPos, DecimalPos, GCRTemp, .
StringLeft, CountMinutes, GCRTemp, %DecimalPos%
GCRTemp = %CountMinutes%
; Now GCRTemp contains something like 0.513, which is the number of
; "partial minutes" remaining that aren't yet reflected in CountMinutes.
GCRTemp *= 60 ; Now GCRTemp contains the number of remaining seconds.
; Truncate the decimal portion, leaving only the whole number of seconds in CountSeconds:
StringGetPos, DecimalPos, GCRTemp, .
StringLeft, CountSeconds, GCRTemp, %DecimalPos%
ConvertResult = %CountDays%d %CountHours%h %CountMinutes%m %CountSeconds%s
return
#4

Posted 06 April 2004  02:03 PM