Categorised Menu List

Calculate TimeDifference

between any two times


between any two time intervals

Public Function GetTimeCardTotal()
    Dim db As Database, rs As Recordset
    Dim totalHours As Long, totalminutes As Long
    Dim days As Long, hours As Long, minutes As Long
    Dim interval As Variant, j As Integer

    Set db = DBEngine.Workspaces(0).Databases(0)
    Set rs = db.OpenRecordset("TbProcessorData")
    interval = #12:00:00 AM#

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Link: Understanding Loops ~~~~~~~~~~~~
        While Not rs.EOF
            interval = interval + rs![TimeSpace]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Link: Understanding Loops ~~~~~~~~~~~~

    totalHours = Int(CSng(interval * 24))
    totalminutes = Int(CSng(interval * 1440))
    totalSeconds = Int(CSng(interval * 86400))
    hours = totalHours Mod 24
    minutes = totalminutes Mod 60
    Seconds = totalSeconds Mod 60
    GetTimeCardTotal = totalHours & " hours " & minutes & " minutes and " & Seconds & "seconds"
End Function

Issues you may encounter: While you copy and paste the code from here to code window, replace double quotes in code window again, as these quotes will appear as smart quotes.


Original Code, Company names and user names are replaced with false names.

It is always advisable to make best use of status bar.  Application.StatusBar = "some text"

This will help end user to know that the work is in progress...