Brian Dunning's FileMaker Custom Functions

CF.TextToTime ( TXT ; F ; L )

Coverts the first 3 up to 7 numbers of a text string into a time indication (hours, minutes, seconds).

  Average rating: 4.4 (24 votes) Log in to vote

Thomas Hellwig   Thomas Hellwig
Delasocial GmbH, Hamburg (Germany)
http://www.delasocial.com

Share on Facebook Share on Twitter

  Sample input:
CF.TextToTime ( "ABC250761" ; 1 ; 0)
CF.TextToTime ( "milliseconds0155900" ; 3 ; 3 )
CF.TextToTime ( "61594" ; 2 ; 0 )
  Sample output:
25:08:01
01:55:900
01:59

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

Description:
Coverts the first 3, 4, 5, 6, or 7 numbers of a text string into a time indication (like hours:minutes or hours:minutes:seconds or minutes:seconds:milliseconds).

Version:
2.0: Completely revised code.
3.0: New Format "mm:ss" as code 2 and "ss:ms" as code 4. Additional parameter (L) for the numbers of digits of milliseconds.
3.1: Bugfix

Parameters:
(TXT) Possible values:
A text string with numbers ---> e.g. "Your time is 8 min and 23 sec." or "12445" or "089 hu!77-3p"

(F) Possible values:
Output format code:
0 ---> without seconds (hh:mm)
1 ---> with seconds (hh:mm:ss)
2 ---> without hours (mm:ss)
3 ---> without hours, but with milliseconds (mm:ss:ms)
4 ---> without hours and minutes (ss:ms)

(L) Lenght of millisecongs (number of digits):
0 ---> if not needed
1 ---> 1 digit
2 ---> 2 digits
3 ---> 3 digits

 

Comments

Lee Smith   Lee Smith
Mar 10, 2016
Your custom function is stumbling on “SetzeVars” as if I’m supposed to have a CF with that name, or the English version of what that does.
 
Thomas Hellwig   Thomas Hellwig, Hamburg/Germany
Mar 10, 2016
Please note that the FileMaker version is 12. The function "SetzeVars" is renamed in version 13.
I hope this information is helping you.
 
Lee Smith   Lee Smith
Mar 10, 2016
I guess I’m fighting more than one issue, the version I’m using is 14 and the Calc is in German which I don’t know the the equivalent of English from German.
 
Thomas Hellwig   Thomas Hellwig, Hamburg/Germany
Mar 11, 2016
You can use the tool "Language Switcher" to start FileMaker in german. But the code above will be also switched automatically if you copy it into the Specify Calculation.

Here it is in english:

Let (
[
FZS = Filter ( TXT ; "0123456789" ) ;
AZ = Case ( Length ( FZS ) = 1 ; GetAsText ( "0" & FZS ) ; FZS ) ;
P = Left ( GetAsText ( AZ & "000000" ) ; 6 ) ;
SEC = Case ( M = 1 ; 8 ; 5 ) ;
Z = Left ( Time ( Left ( P ; 2 ) ; Middle ( P ; 3 ; 2 ) ; Right ( P ; 2 ) ) ; SEC )
]

; //______________________________ Calculation

Z

) //___ EndLet
 
Thomas Hellwig   Thomas Hellwig, Hamburg/Germany
Apr 2, 2016
Version 2.0 has a complete new structure and is reduced to three codes for three output formats:
0 ---> without seconds (hh:mm)
1 ---> with seconds (hh:mm:ss)
2 ---> without hours, but with milliseconds (mm:ss:ms )
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: