Brian Dunning's FileMaker Custom Functions

formatTime ( numbersOnlyMilitaryTime )

Takes input of numbers (only) and converts to properly formatted military time

  Average rating: 4.6 (31 votes) Log in to vote

Timothy Hall   Timothy Hall
beezwax datatools, inc.
http://beezwax.net

Share on Facebook Share on Twitter

  Sample input:
formatTime ( "234" )
or
formatTime ( "0234" )
or
formatTime ( "23456" )
or
formatTime ( "023456" )
  Sample output:
02:34:00
or
02:34:00
or
02:34:56
or
02:34:56

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

Use with either a numeric or time field.
Will convert number-only entries into hh:mm:ss military time format.

USAGE:
Make the field a number field with an auto-enter calculation of..
If( IsEmpty( Self ) ; GetAsText("hhmmss") ; GetAsText(formatTime( Self )) ).
NOTE: You can also use conditional formatting to display the "hhmmss" prompt in the field as a dimmed value.
Set the auto-enter calculation with "Do not replace.." (unchecked).

CAVIET: if you use a time field, once a value has been entered, and then the field value is deleted by the user, the "hhmmss" prompt will display a question mark.
The WORK-AROUND: use an additional conditional formatting rule to hide the question mark.

FINAL NOTE: for use with FMGo in the iPad or iPhone, time fields do not support military time (as of this writing), and users will have to enter standard time values - the field's time format can be set in the inspector to display the result in military time though.

If time-range searches will be needed, you could use a second calculation field, set to time, that displays the value of the converted number field; place the time field over the number field on your layout, and set the time field for entry in find mode, and the number field for entry in browse mode - this would cover the range searches in find mode.

Enjoy.

 

Comments

jcm38   jcm38, Grenoble
May 21, 2014
Thank you for this usefull function.
JCM
 

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.

Under construction. Email me your wish list for improvements.