VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Get Hours, Minutes, AND Seconds between 2 Dates (or of total seconds)

by Sparq (34 Submissions)
Category: Math/Dates
Compatability: Visual Basic 5.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (4 Votes)

This code will enable you to take two dates, find the total seconds in between them, and calculate the Hours, Minutes, and Seconds.

Rate Get Hours, Minutes, AND Seconds between 2 Dates (or of total seconds)




Dim H, M, S, Secs as Long

 Secs = DateDiff("s", Date1, Date2)

 H = Int(Secs / 3600)

 Secs = Secs - (H * 3600)

 M = Int(Secs / 60)

 Secs = Secs - (M * 60)

 S = Secs

 MsgBox Format(H, "00") & ":" & _

   Format(M, "00") & ":" & _

   Format(S, "00")

Download this snippet    Add to My Saved Code

Get Hours, Minutes, AND Seconds between 2 Dates (or of total seconds) Comments

No comments have been posted about Get Hours, Minutes, AND Seconds between 2 Dates (or of total seconds). Why not be the first to post a comment about Get Hours, Minutes, AND Seconds between 2 Dates (or of total seconds).

Post your comment

Subject:
Message:
0/1000 characters