Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Time input simplified

Featured Replies

I would like my users to input the time in the format HHMM (ie, just numbers, without any delimeter), and it should automatically convert it to correct time format. I have experimented a bit with this, but can't get it to work 100%. 

Eg; with the below calculation it works for all times after noon. Ie, "1215" converts it correctly to 12:15, but "0830" will not (it will be converted to "83:00").

Let ( $Timein = GetAsText ( indata ) ; 
Time ( Left ( $Timein ; 2 ) ; Middle ( $Timein ; 3; 2 ) ; "00" ) 
)

 

Is there anyone that already have done this satisfactory? 

What do you want to see if it’s 12:15am, and how should it be entered?

Are you counting on the user to correctly enter 0015?

Maybe double pop ups, tied to value lists-one for hours, one for minutes.

Edited by Steve Martino

  • Author

1215am should be seen as 00:15 (because we use 24h format in Sweden where I am).

Yes, the user will enter 0015 as the input data. No more, no less. ;) 

 

This works for me:

Let (
[TimeEntered = Get ( ActiveFieldContents );
TimeCalc = Right("0000" & Filter ( TimeEntered ; "0123456789" );4)];

Left (TimeCalc; 2 ) & ":" & Right ( TimeCalc ; 2 )

 )

Edited by Fran_g
added info - used as script trigger OnObjectValidate

I would use two fields for this:

  • TimeEntry (Number)
  • Timefield (Time)

Define Timefield to auto-enter calculated value (replacing existing value) =

Time ( Div ( TimeEntry ; 100 ) ; Mod ( TimeEntry ; 100 ) ; 0 )

On the layout, place TimeEntry behind Timefield and make Timefield non-enterable.

3 hours ago, Fran_g said:

This works for me:

it did not work for me. I see now that you have added that it needs to be entered via a script trigger. This could work, but there is a problem: suppose user enters "1245". This is correctly converted to time 12:45:00 and displayed as 12:45. Now if user clicks into the field and corrects the entry to 12:50:00, the result will be time 50:00:00. I believe this could be fixed (as well as simplified a bit) by making the script set the time field to =

Let ( [
entry = Get ( ActiveFieldContents ) ;
n = Filter ( entry ; "0123456789" )
] ;
If ( 
PatternCount ( entry ; ":" ) ; entry ;
Time ( Div ( n ; 100 ) ; Mod ( n ; 100 ) ; 0 )
)
)

 

 

Edited by comment

It still works for me - I don't have the problem you describe  (FM version 11; Windows 7).

The field is set to select entire contents on entry and formatted to show 12 hour format with AM and PM

As you note, I edited the post to add the  information I forgot to put in the orginal reply about the field having a script trigger attached.

 

  • Author
On 6/6/2019 at 7:18 AM, Fran_g said:

This works for me:

Let (
[TimeEntered = Get ( ActiveFieldContents );
TimeCalc = Right("0000" & Filter ( TimeEntered ; "0123456789" );4)];

Left (TimeCalc; 2 ) & ":" & Right ( TimeCalc ; 2 )

 )

Are you sure?

Because when I enter "2030" gives the output "2030:00:00"... 🤔

On 6/6/2019 at 10:02 AM, comment said:

I would use two fields for this:

  • TimeEntry (Number)
  • Timefield (Time)

Define Timefield to auto-enter calculated value (replacing existing value) =


Time ( Div ( TimeEntry ; 100 ) ; Mod ( TimeEntry ; 100 ) ; 0 )

On the layout, place TimeEntry behind Timefield and make Timefield non-enterable.

 

If two fields are needed, then I have to use two fields. I would of course rather only have one field, but I have also thought that this maybe would be necessary...

On 6/5/2019 at 9:20 PM, Steve Martino said:

 

Still, these are time pickers. I would rather just use a simple input field with four numbers, that is converted to a correct time.

52 minutes ago, carlsson said:

I would of course rather only have one field,

One field with a script trigger, as suggested by @Fran_g (with my correction), can work - see the atached demo.

Note that leading zeros are not required.

TimeEntry.fmp12

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.