Formatting 24 hour time

For HanDBase related topics that are not specific to one platform.

Formatting 24 hour time

Postby carmaro44 » Wed Jan 24, 2018 6:39 pm

I like using 24 hr format on PCs, iPad, and iPhone. I have a very simple database to track a periodic medication that I take. It only has a text Drug, time TimeTaken date DateTaken. Time always appears as hh:'mm:ss. First of all, I don't want seconds to display at all but can't figure out how to trim it. Second, there might be a need to have seconds for another application, but if I edit a value in a time field using the default iOS picklist, it does not allow editing of the seconds and always defaults to '00'.

So a couple of questions:
1. How do I get it to format as 'hh:mm' when a record is created? (is there a format function I can't find?)
2. How do I get the picklist to allow selection of seconds when editing?

Thanks in advance for any help!
Posts: 1
Joined: Wed Jan 24, 2018 5:44 pm

Re: Formatting 24 hour time

Postby ddhsoftwareadmin » Sun Jan 28, 2018 7:09 pm

Hi Rich,

Thanks for your post. The time format comes from the OS- HanDBase supplies the time and the OS formats it based on your locale. Unfortunately there isn't an option in HanDBase to control the display. I can't easily add that to the database format, but I could potentially make a preference to show/hide seconds for time fields- not sure if this will suffice as some times you may want the seconds and other times you may not want them, so a global toggle doesn't always suit the bill.

So unfortunately there isn't any option to hide or show the seconds, or a way to pick seconds from the time picker at this time. That said, there is a tricky workaround you can do and it especially works well with custom forms. Here's the basics:

<b>Have a time field and get rid of the seconds:</b>
Add a calculated field that gets rid of the seconds. The Time field when included in a calculation is the number of seconds since the beginning of the day. So the formula to get rid of the seconds would be: Time Value - (Time value Mod 60 ). Set the output to be a time value and you should get a time field with zero seconds all the time. In the form you show the output of the calc field and a button that points to the Time value itself.

<b>Select seconds for a time field</b>
You can combine the above with a drop down list for seconds- have a popup list with the values 0 to 59. Use the 'secondless' time out and in your formula add the value of this popup to it. Now you have a way to select seconds for a time field.

These are both a bit of a hack- wish there was a more official way, but hopefully the above is of use to you!
Site Admin
Posts: 427
Joined: Tue Dec 09, 2008 2:13 pm

Return to HanDBase General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest