asp下用datediff实现计算两个时间差的函数
程序员文章站
2022-05-18 11:38:08
计算两个时间差的函数 '****************************** '||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下使用数组存放数据的代码