Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Time formatting

Status
Not open for further replies.

laina222

Technical User
Sep 7, 2001
172
US
I have a time field that is currently formatted as a five or six digit number depending on what time of the day it is.
Example: 8:30 AM = 83000
11:45 AM = 114500
I want to format these numbers into the standard HH:MM:SS format, but don't know the code to do that.

Also, is there any way to calculate the time between these two times? For the above two times, the result would be 3:15:00.
Thanks in advance for any help!
 
1. Format(time, "HH:MM:ss")

2. Dim a as date
dim b as date

a = #8:30 AM#
b = #11:45 AM#

msgbox (b - a)



-bclt
 
[tt]Dim A As Long, B As Long
Dim D1 As Date, D2 As Date

A = 83000
B = 114500

D1 = Format$(A, "@@:mad:@:mad:@")
D2 = Format$(B, "@@:mad:@:mad:@")

Debug.Print D1, D2
Debug.Print Format$(D2 - D1, "HH:MM:SS")[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top