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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

24 Hour Time 1

Status
Not open for further replies.

tmcneil

Technical User
Nov 17, 2000
294
US
I have a field that i created from taking local time and subtracting or adding the time zone to get GMT. I would like to be able to change GMT to 24 Hour and then throw the 24 Hour GMT value into a text field as text. An example of the value I have is this:

3/30/2001 11:45:00 PM

I use the data at the beginning to figure out when the time goes over midnight to the next day. If it does, 3/31/01 will show. I can easily change the column to show Short Time, ie., 23:45. However, how can I get 23:45 to show up as a string in a string field?

Thanks,
Todd
 
Todd,
Try surrounding the time in a
Code:
CStr(MyTime)
function. It should work to extract a string like you want.

HTH
Scotty ::) Become better informed. Lean from others' mistakes. You could not live long enough to make them all yourself."
-- Hyman George Rickover (1900-86),
 
Not sure if Cstr function would work. The example, 3/30/2001 11:45:00 PM, is actually considered a date/time value. So, getting it to be shown as a 24 Hour GMT value in a string field maybe more difficult than that. If I can write something to parse out strings, ie.,

1. an hour string
2. a colon string
3. a minute string

and then piece these three together to get a string. But, how can I store this, 3/30/2001 11:45:00 PM, into something I can use before i parse it? I hope this question now makes more sense.

Todd
 
Could you use format([Time],"mm/dd/yyyy hh:nn:ss am/pm")
 
This works for me:
if the time is 2:34 PM
Format(Now(), "H:nn") yields 14:34
RGB
 
rather shakesperian? RGB rates a Star. MichaelRed
mred@att.net

There is never time to do it right but there is always time to do it over
 
Here is a function I used to get what I needed:

Function fnTime2String(DEP_GMT As String)

fnTime2String = Format(DEP_GMT, "H:nn")

End Function

Thanks for the help to all that responded.

Todd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top