Time drop down that displays am/pm but inputs military time

sheckay

Member
Local time
Today, 02:52
Joined
May 6, 2022
Messages
37
Hello. This might be a ridiculous question, but I'll ask it anyway. Is it possible to create a drop down for time (with 15 minute intervals) that allows the user to choose from an AM/PM setup, but after choosing the value Access would translate that into military time in the field?
Thanks in advance.
 
Time is time - its stored as a decimal number as seconds/86400 (the number of seconds in a day - so 12 noon=0.5, 6am=0.25, etc

So what you see is just a format. It’s not recommended to use a format in a field as it can hide the underlying value, but you can set the format in a form control.

If by ‘field’ you actually mean the combo control, it can probably be done by having two columns the first with military time and the second with am/pm time with column width set to 1. On dropdown event use code to change the 1to 0 to hide the first column then on lost focus or before update event change it back to 1. You’ll need to experiment to see which events work for you
 
Put the times in the drop-down in military time but have the format use the AM/PM formatting options. If the relevant field in the combo is type Date/Time, then "military time" is internally the data format in use. Stated another way, the AM/PM display is a format choice, not a data choice.
 
Put the times in the drop-down in military time but have the format use the AM/PM formatting options. If the relevant field in the combo is type Date/Time, then "military time" is internally the data format in use. Stated another way, the AM/PM display is a format choice, not a data choice.
OK, that sounds like something I can figure out. Thank you! Thank you, too, CJ
 
Your request is confusing. Groups who use military time would never want to switch to AM/PM for data entry. Also, as Doc mentioned. Dates are NOT stored as strings anyway so how a date is stored internally is under the control of Jet/ACE and not you. Can you explain your logic with this request so we can understand what question we are really answering?
 
Your request is confusing. Groups who use military time would never want to switch to AM/PM for data entry. Also, as Doc mentioned. Dates are NOT stored as strings anyway so how a date is stored internally is under the control of Jet/ACE and not you. Can you explain your logic with this request so we can understand what question we are really answering?
Thanks for the reply. I'm looking for something that's convenient for users that are used to the am/pm setup. But military time being what's actually entered for the calculations to work right. The calculations are just a beginning time being subtracted from an end time to give you a total time in hours.
 
Thanks for the reply. I'm looking for something that's convenient for users that are used to the am/pm setup. But military time being what's actually entered for the calculations to work right. The calculations are just a beginning time being subtracted from an end time to give you a total time in hours.
Time is time. It is stored as a double precision number. It is NOT stored as standard or military. Those are string formats which would never be used for any calculations. So, I hope you are not converting your time field to a string in order to do calculations.

When the user enters a time, he just types a or p after the hh:mm and tabs and Access fills in the rest. A combo would be overkill.
 
Time is time. It is stored as a double precision number. It is NOT stored as standard or military. Those are string formats which would never be used for any calculations. So, I hope you are not converting your time field to a string in order to do calculations.

When the user enters a time, he just types a or p after the hh:mm and tabs and Access fills in the rest. A combo would be overkill.
OK, I wasn't aware of the p trick. I'll test that out and see if it works. Thank you.
 
Please tell me you are not formatting a date into a string before trying to use it in a calculation.
 
I have never formatted a date into a string.
Just curious - you have never used the format function? never passed a date control on a form as a parameter to a query?
 

Users who are viewing this thread

Back
Top Bottom