Formatting access cells for inputing data in hh:mm format

amit.uasd

New member
Local time
Today, 09:52
Joined
Dec 9, 2018
Messages
1
I want to make access form to enter data in [h]:mm format e.g. 235:24 (read as 235hrs and 24 minutes). After inputting data in this format I want to make various calculation on it and store the result in same format. Please suggest how to do it. Thanks in advance.
 
You can't do this using the datetime datatype as the max value is 23:59:59.
You will need to use a text field instead if you need that format.
 
These helper functions (untested) might be useful if you go that route with a text fields
Code:
Public Function GetHours(SomeField as variant) as integer
  if not isnull(someField) then
    getHours = split(somefield,":")(0)
  end if
end if

Public Function GetMinutes(SomeField as variant) as integer
  if not isnull(someField) then
    getMinutes= split(somefield,":")(1)
  end if
end if
Public Function GetSeconds(SomeField as variant) as integer
  if not isnull(someField) then
    if ubound(split(somefield,":") = 2 then
      getSeconds = split(somefield,":")(2)
  end if
end if
The other option is to simply save minutes in one field or hours and minutes in two fields.
 
@june7
How is degree, minutes, seconds related to hours: minutes? Its a good link, but do not get the relation.
 
hours:minutes:seconds (elapsed quantity, not clock time) or degrees:minutes:seconds, the calculations to convert to/from decimal hours or decimal degrees are the same. Exclude seconds if that precision is not needed.
 
Last edited:
MajP - you see that format in navigation a lot. When I worked with the oil industry and they did underwater seismic imaging near certain Pacific islands, we would see longitudes between 160 and 180 degrees (E or W). A longitude of 179:59:59 at the equator is about 70/3600 or just under 0.02 miles from the international date line.

But the math is the same either way - just sexagesimal arithmetic.
 
Thanks for the clarification. Brain fart on my end.
 

Users who are viewing this thread

Back
Top Bottom