VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



A function that returns the difference between two dates in hours minutes and seconds

by Nick Sutton (1 Submission)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Mon 4th March 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

A function that returns the difference between two dates in hours minutes and seconds

Rate A function that returns the difference between two dates in hours minutes and seconds



        TotalSeconds = DateDiff("s", Format(StartDate, "dd/mm/yyyy hh:mm:ss"), Format(FinishDate, "dd/mm/yyyy hh:mm:ss"))
        If TotalSeconds > 59 Then
            ExecutionMinutes = Int(TotalSeconds / 60)
            
            If ExecutionMinutes > 59 Then
                ExecutionHours = Int(ExecutionMinutes / 60)
                ExecutionMinutes = Int(ExecutionMinutes - (ExecutionHours * 60))
                ExecutionSeconds = Int(TotalSeconds - ((ExecutionHours * 3600) + ExecutionMinutes * 60))
            Else
                ExecutionSeconds = TotalSeconds - (ExecutionMinutes * 60)
                executiontime = ExecutionMinutes & " minutes and " & ExecutionSeconds & " seconds"
            End If
        Else
            executiontime = TotalSeconds & " seconds"
        End If
        
        GetExecutionTimeFor = executiontime
End Function

'To Test Try
MsgBox GetExecutionTimeFor("04/04/2002 01:12:30", "04/04/2002 02:15:50")

Download this snippet    Add to My Saved Code

A function that returns the difference between two dates in hours minutes and seconds Comments

No comments have been posted about A function that returns the difference between two dates in hours minutes and seconds. Why not be the first to post a comment about A function that returns the difference between two dates in hours minutes and seconds.

Post your comment

Subject:
Message:
0/1000 characters