计算两个时间之差的函数
程序员文章站
2022-05-18 11:16:21
'****************************** '||function timediff(sbegin, send) '||本函数计算两...
'******************************
'||function timediff(sbegin, send)
'||本函数计算两个时间的差,可以不用更改直接使用
'||作者:machinecat 2001/10/26
'******************************
'******************************
'注:首先需要判断用户输入的sbegin与send之间的大小
'可以通过datadiff函数获得两者之间的时间差,不需要进行复杂的时间换算
function timediff(sbegin, send)
dim ihourb, iminuteb, isecondb, iminisecondb
dim ihoure, iminutee, iseconde, iminiseconde
dim dtimeb, dtimee, dtimediff
dim ihour, iminute, isecond, iminisecond
ihourb = clng(left(sbegin, 2))
iminuteb = clng(mid(sbegin, 4, 2))
isecondb = clng(mid(sbegin, 7, 2))
iminisecondb = clng(mid(sbegin, 10, 4))
ihoure = clng(left(send, 2))
iminutee = clng(mid(send, 4, 2))
iseconde = clng(mid(send, 7, 2))
iminiseconde = clng(mid(send, 10, 4))
dtimeb = ihourb * 3600 + iminuteb * 60 + isecondb + iminisecondb / 1000
dtimee = ihoure * 3600 + iminutee * 60 + iseconde + iminiseconde / 1000
dtimediff = dtimee - dtimeb
ihour = int(dtimediff / 3600)
dtimediff = dtimediff - ihour * 3600
iminute = int(dtimediff / 60)
dtimediff = dtimediff - iminute * 60
isecond = int(dtimediff)
dtimediff = dtimediff - int(dtimediff)
iminisecond = dtimediff
timediff = ihour & "小时" & iminute & "分钟" & isecond & formatnumber(iminisecond, 3) & "秒"
end function
'||function timediff(sbegin, send)
'||本函数计算两个时间的差,可以不用更改直接使用
'||作者:machinecat 2001/10/26
'******************************
'******************************
'注:首先需要判断用户输入的sbegin与send之间的大小
'可以通过datadiff函数获得两者之间的时间差,不需要进行复杂的时间换算
复制代码 代码如下:
function timediff(sbegin, send)
dim ihourb, iminuteb, isecondb, iminisecondb
dim ihoure, iminutee, iseconde, iminiseconde
dim dtimeb, dtimee, dtimediff
dim ihour, iminute, isecond, iminisecond
ihourb = clng(left(sbegin, 2))
iminuteb = clng(mid(sbegin, 4, 2))
isecondb = clng(mid(sbegin, 7, 2))
iminisecondb = clng(mid(sbegin, 10, 4))
ihoure = clng(left(send, 2))
iminutee = clng(mid(send, 4, 2))
iseconde = clng(mid(send, 7, 2))
iminiseconde = clng(mid(send, 10, 4))
dtimeb = ihourb * 3600 + iminuteb * 60 + isecondb + iminisecondb / 1000
dtimee = ihoure * 3600 + iminutee * 60 + iseconde + iminiseconde / 1000
dtimediff = dtimee - dtimeb
ihour = int(dtimediff / 3600)
dtimediff = dtimediff - ihour * 3600
iminute = int(dtimediff / 60)
dtimediff = dtimediff - iminute * 60
isecond = int(dtimediff)
dtimediff = dtimediff - int(dtimediff)
iminisecond = dtimediff
timediff = ihour & "小时" & iminute & "分钟" & isecond & formatnumber(iminisecond, 3) & "秒"
end function
上一篇: asp数据库连接函数
下一篇: 一个不太让人讨厌的自动弹出窗口