注册 登录
Office中国论坛/Access中国论坛 返回首页

的个人空间 http://www.office-cn.net/?0 [收藏] [复制] [分享] [RSS]

日志

自定义时差函数(加入跨天计算功能)

已有 163 次阅读2008-1-17 10:13 |个人分类:ACCESS作品

通过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



20074312522895956.rar

评论 (0 个评论)

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 注册

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-5-26 04:39 , Processed in 0.054252 second(s), 14 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

返回顶部