Dates and Times

julietbrown

New member
Local time
Today, 04:45
Joined
Aug 23, 2004
Messages
9
Thanks to those who solved this. (I did consult Help first, but with no success ... I am using Access in Office 97, so maybe help is more helpful in later versions!)

Having horrid problems. You can use DatePart() to get the date part of a DateTime field, but HOW do you get the "TimePart" out? Also, if you choose format "long time" for a field it seems to default to a date part that is today's date .... I just want the time. (I'm trying to do 'finish_time - start_time' to get elapsed time for a race, and am getting the most bizarre results, dated something like 1735!!)
 
Last edited:
try using the format function

For example:

=Format([fieldname], "hh") will return the hour part.
 
Dates are actually fixed-point decimals under the hood, so your bizarre result comes from subtracting one date from another directly and getting an answer that is nearly zero.

Don't worry about any of that... the following should give you what you want (assuming that your race doesn't go on for more than 24 hours)...

Format(finish_time - start_time, "hh:nn:ss")
 
The DatePart function works with time too. You'd have known that if you'd taken the time to consult the Access Help first. ;)

i.e.

Code:
Dim byt As Byte
byt = DatePart("h", Now)
MsgBox byt
 

Users who are viewing this thread

Back
Top Bottom