Hours & Minutes

shonaart

New member
Local time
Tomorrow, 01:21
Joined
Aug 24, 2009
Messages
4
Hi
Please can you help me. I use the Hours and Minutes in Excel ( 2007 ) format : [H]:MM , which is Hours and minutes.
Its NOT as in time like 21H10 , its stands for 123 hrs and 30 min.

I need to enter this in access and i seem not be able to find. How do i get to be able for my field to be in that format ? What can I do ?


Thanks for all you help
Vaughan
 
In design mode on your table, make sure that your field is designated as a Date/Time type field. Then use the Short Time format (12:12).
 
Hio
Will that short date (12:12) be able to have ie: 30:20 min. Will I be able to enter more than 24hours ?
Thanks

Just checked, No it does not work. That is time as in 12H30 in the day. I am looking for Hours & Min. Thanks
 
Last edited:
Formatting your control as I described will restrict you to a 23:59 entry.
 
In general it's not a good idea to use a Date/time datatype for storing hours and minutes. This is because Access always treats the data as a date & time. Better to use a number field and store the number of minutes, or 2 fields for hours and minutes.
 
Why dont you simply save the hours and minutes as a integer in one field then use a simple function to convert it to the format you require

Code:
Public Function MinsToTime(AnyMins As Integer) As String

Dim Hrs As Integer, Mins As Integer

Select Case AnyMins
   Case <1 : MinsToTime = "00H00"
   Case <60 :MinsToTime = "00H" & Cstr(AnyMins) 
   Case Else
    Hrs = Int(AnyMins/60)  
    Mins = AnyMins - (Hrs * 60)
    MinsToTime = CStr(Hrs) & "H" & CStr(Mins)
End Select

End Function

Then in a query simply call

Code:
Duration: MinsToTime([YourFieldHere])


David
 

Users who are viewing this thread

Back
Top Bottom