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

HOW TO EXTRACT TIME FROM A DATE STAMP. 1

Status
Not open for further replies.

Brianus

Programmer
Jul 5, 2006
11
US
Ladies and gentlemen,
please I need your help:

Date stamp: 02/13/06 19:45:22

is there a function in VBA/VB to extract the time stamp(19:45:22) from the above date stamp, rather than using the Left$, mid$ and right$ functions. What is the appropriate code?
Thans a mil.
B.
 
I would use the Format function

Format(02/13/06 19:45:22,"hh:mm:ss")

I tried to have patience but it took to long! :) -DW
 
Hi -

Applying formatting to a date/time returns a string, which may not be helpful if you intend to use any of the built-in date time functions. Look at this MSKB article to see how Access stores date/time [URL unfurl="true"]http://support.microsoft.com/kb/q130514/[/url]

Consider the TimeValue() function, e.g. from the debug (immediate) window:
Code:
x = #02/13/06 19:45:22#
y = TimeValue(x)
? y
7:45:22 PM 

'to show that y is stored in Date/Time data type
? cdbl(y)
 0.823171296296296 

'to display in military/European time rather than AM/PM
? format(y, "Short Time")
19:45

HTH - Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top