|
通过datediff()函数综合运用,加入跨天计算时差,得出精确到分钟的时间差
函数模块代码:
''--------------------------------------------------------------
''计算时差函数
''
''例:TimeDiff([开始日期],[结束日期],[开始时间],[结束时间])
''输出:字符串 格式 (hh:nn)
''
''编程:江羽
''--------------------------------------------------------------
Public Function TimeDiff(StarD As Date, EndD As Date, StarT As Date, EndT As Date) As String
Dim myDateDiff As Date
Dim myMinuteDiff As Date
myDateDiff = Datediff("d", StarD, EndD)
myMinuteDiff = Datediff("n", StarT, EndT)
''判断日期是否超过一天
If myDateDiff > 0 Then
myMinuteDiff = Datediff("n", StarT, EndT) + myDateDiff * 24 * 60
Else
myMinuteDiff = Datediff("n", StarT, EndT)
End If
TimeDiff = Format(Int(myMinuteDiff / 60), "00") & ":" & Format(myMinuteDiff Mod 60, "00")
End Function
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|