carlsson Posted June 5, 2019 Posted June 5, 2019 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?
Steve Martino Posted June 5, 2019 Posted June 5, 2019 (edited) 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 June 5, 2019 by Steve Martino
carlsson Posted June 5, 2019 Author Posted June 5, 2019 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.
Steve Martino Posted June 5, 2019 Posted June 5, 2019 Google 'FileMaker Time Picker' Here's a few: https://www.filemakermagazine.com/videos/time-picker-widget http://www.modularfilemaker.org/module/time-picker/ http://www.modularfilemaker.org/module/time-picker/ https://hbase.net/2018/09/03/time-picker-for-filemaker-go-on-ios/ 1
Fran_g Posted June 6, 2019 Posted June 6, 2019 (edited) This works for me: Let ( [TimeEntered = Get ( ActiveFieldContents ); TimeCalc = Right("0000" & Filter ( TimeEntered ; "0123456789" );4)]; Left (TimeCalc; 2 ) & ":" & Right ( TimeCalc ; 2 ) ) Edited June 6, 2019 by Fran_g added info - used as script trigger OnObjectValidate
comment Posted June 6, 2019 Posted June 6, 2019 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.
comment Posted June 6, 2019 Posted June 6, 2019 (edited) 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 June 6, 2019 by comment 1
Fran_g Posted June 6, 2019 Posted June 6, 2019 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.
carlsson Posted June 10, 2019 Author Posted June 10, 2019 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: Google 'FileMaker Time Picker' Here's a few: https://www.filemakermagazine.com/videos/time-picker-widget http://www.modularfilemaker.org/module/time-picker/ http://www.modularfilemaker.org/module/time-picker/ https://hbase.net/2018/09/03/time-picker-for-filemaker-go-on-ios/ Still, these are time pickers. I would rather just use a simple input field with four numbers, that is converted to a correct time.
comment Posted June 10, 2019 Posted June 10, 2019 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
Recommended Posts
This topic is 1991 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now