Entering time in a field

G

Gina K

Maybe I'm making this harder than it is...here goes.
I want to enter a time in a field - not a time as in 1:15 PM, but a time as
in 1 minute, 15.5 seconds (1:15.5) (say, for instance, the amount of time it
took a hamster to complete a maze). I'd also like to be able to sort a
report on the data in this field. What data type should I assign to this
field, and is there an input mask/format that will get me the results I'm
looking for?
Sorry for such a newbie question,
Gina
 
R

Rick B

This is a "duration" not a "time" in Access lingo. Access does not have a
built-in format to support durations. This could be entered into a numeric
field as a fraction or you could create multiple fields to support each part
of the figure.

There are many different ways to approach. You should search the
newsgroups and google for "duration" and read some of the previous posts on
the subject.

Good Luck,

Rick B
 
P

Paul Overway

Hamster races...interesting! :eek:)

Unfortunately, the DateTime data type, which would be your most logical
pick, does not have the precision needed to stored tenths of a second and
even less milliseconds. If seconds are adequate, the format would need to
be n:ss

Your other option would be to store the times as text.
 
D

Douglas J. Steele

Actually, the usual recommendation is to pick whatever resolution you want,
and then store the duration in a Long Integer. In other words, if you want
10ths of seconds, and the time is 1:15.5, store that as 755. Create a couple
of functions to convert back and forth, and you're pretty much done.
 
P

Paul Overway

Yes...that would be another way. But given her apology for asking a newbie
question, hard to say whether she wanted to take on writing the functions.
If she stores it as text, she's done...as long she doesn't need to do
calculations.
 
D

Douglas J. Steele

Unfortunately, storing it as text means she won't be able to sort it
properly, one of her requirements.

The times will sort as

1:15.0
10:15.0
11:15.0
2:15.0
3:15.0

not the required

1:15.0
2:15.0
3:15.0
10:15.0
11:15.0

She could include a leading 0 where necessary, but that's ackward:

01:15.0
02:15.0
03:15.0
10:15.0
11:15.0
 
M

Margy

So what is the solution? I have the same problem as Gina. I do want to sort
the times (athletics results ) and work out means and max's and mins
eventually.
Margy
 
J

John Vinson

So what is the solution? I have the same problem as Gina. I do want to sort
the times (athletics results ) and work out means and max's and mins
eventually.

Store the racetimes in seconds and fractional seconds, probably in a
Double.

To format 483.24 seconds in minutes and seconds, use an expression
like

[Racetime] \ 60 & ":" & Format([Racetime] - 60 * ([Racetime] \ 60),
"00.00")


John W. Vinson[MVP]
 
Top