This function calculates the difference of two times
Source: Internet
Author: User
'******************************
'|| Function Timediff (Sbegin, SEnd)
'|| This function calculates the difference of two times and can be used without changing the
'|| Author: Machinecat 2001/10/26
'******************************
'******************************
' Note: First you need to determine the size of the user input between Sbegin and send
' You can get a time difference between the two by using the Datadiff function, and you don't need to do a complicated conversion.
'******************************
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 + isecondb + iminisecondb/1000
Dtimee = ihoure * 3600 + iminutee + 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 & "Hours" & iminute & "Minutes" & Isecond & FormatNumber (Iminisecond, 3) & "seconds"
End Function
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.