Format Time

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

DEAR SIR
I want to use a Feild in Access with time Data type .

Format Time [h]:mm
FOR EXAMPLE 38:05

best regard
 
yousef said:
DEAR SIR
I want to use a Feild in Access with time Data type .

Format Time [h]:mm
FOR EXAMPLE 38:05

best regard

Access doesn't have a DataType that stores an amount of time like that. It
has the DateTime type that stores a point in time including both time and
date. Ths type cannot hold a time value larger than 24 hours because that
increments the Date portion.

Time intervals like you are describing are best stored as long integers that
contain the number of seconds, (or perhaps minutes in your case) and then in
your forms and reports you can use some arithmentic in an expression to
*display* it in the format you want.
 
Rick Brandt's idea is the way to do it. for example, if the value was
entered in a text box as 38:05, then you could use this to covert it to an
number:

varTotTime = Split(txtTime,":")
lngTime = (varTotTime(0) * 60) + varTotTime(1)

And, to display the number:
= Format(lngTime \ 60,"#0") & ":" & Format(lngTime mod 60, "00")

the \ operator is interger division and returns no fraction.
 
There is no inbuilt data type for durations in Access. The DateTime data
type in Access is for points in timeline, not durations.

Probably, the most efficient way is to store as the total number of minutes
(or whatever the smallest unit of time you want to use) and the manipulate
the total mins to h:mm for display when required.
 
Back
Top