Calculate the difference between two time functions

Source: Internet
Author: User

'******************************
'| Function timediff (sbegin, send)
'| The difference between the two time points in this function. You can directly use this function without changing it.
'| Author: machinecat 2001/10/26
'******************************

'******************************
'Note: First, you need to determine the size between the sbegin and send entered by the user.
'The time difference between the two can be obtained through the datadiff function without complicated time conversion.CopyCodeThe Code is as follows: 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 & "Hour" & iminute & "Minute" & isecond & formatnumber (iminisecond, 3) & "second"
End Function

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.