Function ElapsedTime( _ endTime As Date, _ startTime As Date _ ) As String Dim Interval As Date ' Calculate the time interval. Interval = endTime - startTime ' Format and print the time interval in ' days, hours, minutes and seconds. ElapsedTime = _ Int( _ CSng( _ Interval _ ) _ ) & _ " days " & _ Format( _ Interval, _ "hh" _ ) & _ " Hours " & _ Format( _ Interval, _ "nn" _ ) & _ " Minutes " & _ Format( _ Interval, _ "ss" _ ) & _ " Seconds" End Function
This has been adapted from https://docs.microsoft.com/en-us/office/vba/access/concepts/date-time/calculate-elapsed-time
Leave a Reply