Tuesday, July 28, 2009

Military Time Calculation

Dim startTime As String = "330"
Dim stopTime As String = "1224"

startTime = startTime.PadLeft(4, "0")
stopTime = stopTime.PadLeft(4, "0")
Dim dtA As DateTime = DateTime.ParseExact(startTime, "HHmm", Nothing)
Dim dtB As DateTime = DateTime.ParseExact(stopTime, "HHmm", Nothing)
Dim ts As TimeSpan = dtB.Subtract(dtA)

Debug.Print("Time: " & ts.Hours & ":" & ts.Minutes.ToString("00"))

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.

More Important Links

Followers