Formatting access cells for inputing data in hh:mm format (1 Viewer)

amit.uasd

New member
Local time
Tomorrow, 05:06
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.
 

isladogs

MVP / VIP
Local time
Today, 23:36
Joined
Jan 14, 2017
Messages
18,186
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.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 19:36
Joined
May 21, 2018
Messages
8,463
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.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 19:36
Joined
May 21, 2018
Messages
8,463
@june7
How is degree, minutes, seconds related to hours: minutes? Its a good link, but do not get the relation.
 

June7

AWF VIP
Local time
Today, 15:36
Joined
Mar 9, 2014
Messages
5,423
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:

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 18:36
Joined
Feb 28, 2001
Messages
27,001
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.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 19:36
Joined
May 21, 2018
Messages
8,463
Thanks for the clarification. Brain fart on my end.
 

Users who are viewing this thread

Top Bottom