在写程序时,很多时候都要用到两个给定时间的时间差,所以特地把这个函数写出来以便以后可以方便的调用:
function GetDoTime(Time1, Time2)
Dim stime
If Time1 > Time2 Then
stime = Time1
Time1 = Time2
Time2 = stime
End If
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
secvalue = secondvalue - dayvalue * 24 * 3600 - hourvalue * 3600 - minitevalue * 60
If secvalue < 0 Then minitevalue = minitevalue - 1: secvalue = 60 + secvalue
GetDoTime=dayvalue & "天" & hourvalue & "小时" & minitevalue & "分" & secvalue & "秒"
End function
3COME考试频道为您精心整理,希望对您有所帮助,更多信息在http://www.reader8.com/exam/