Function GetDoTime(time1, time2)
secondvalue = DateDiff("s", time1, time2)
dayvalue = DateDiff("d", time1, time2)
hourValue = Fix((secondvalue - dayvalue * 24 * 3600) / 3600)
If hourValue < 0 Then dayvalue = dayvalue - 1: hourValue = 24 + hourValue
minitevalue = Fix((secondvalue - dayvalue * 24 * 3600 - hourValue * 3600) / 60)
If minitevalue < 0 Then hourValue = hourValue - 1: minitevalue = 60 + minitevalue
secondvalue = secondvalue - dayvalue * 24 * 3600 - hourValue * 3600 - minitevalue * 60
If secondvalue < 0 Then minitevalue = minitevalue - 1: secondvalue = 60 + secondvalue
If dayvalue > 0 And hourValue >= 0 Or hourValue = -1 Then hourValue = 24 + hourValue
GetDoTime = hourValue & ":" & minitevalue & ":" & secondvalue
End Function
此代码能计算不超过2天的时间差,精确到秒值.