Software Venture Consulting

FileMaker Pro downloads & Resources
FileMaker Custom Functions
FileMaker Web Viewer Examples
FileMaker Pro & Lasso Consulting
FileMaker Books
FileMaker Articles
FileMaker Error Reference

Free Web Tools
Free FileMaker Tools

Personal Pages

Shopping Cart
Shopping Cart


Free Newsletter


Privacy Policy

FileMaker is a registered trademark of FileMaker, Inc. in the U.S. and other countries.


 FileMaker Pro Custom Functions

List  |  Show Random  |  Upload  |  Add This to Your Site

TimeFormatAs ( theTime ; type12or24 )

Rate this function:  

  Average rating: 4.3  (51 votes)
  Discuss this Custom Function

Jonathan Mickelson, Thought Development Corp.

Formats time data as 12 or 24 hour time at the data level, rather than field format display level. Especially useful for users that desire 12-hour formatted time data.

Sample Input:
TimeFormatAs ( "10:30 AM" ; 24 )
TimeFormatAs ( "00:30:00" ; 12 )
TimeFormatAs ( "16:00" ; 12 )
TimeFormatAs ( "4:23 PM" ; 24 )
Sample Output:
"12:30 AM"
"4:00 PM"
"4:23 PM"

 Then copy & paste into FileMaker Advanced's Edit Custom Function window.


Modification Date: 4/12/2010
- Fixed behavior for better consitency due to changes in Time calculation results in FileMaker over the last few Versions (8-11).
- Fixed bug, reported by Will Loving: in 24 hr mode, "4:23 PM" time returned "4:23 PM" rather than the expected "16:23:00".
- Tweaked behavior to better handle valid FileMaker times like 11:65:65, to add extra any overage amounts of lesser time parts to their higher counterparts correctly, to make it a clock-compatible time, 12:06:05.
- Made separator between AM/PM and time a variable for easy output tweaking.

Modification Date: 2/12/2012
- Fixed behavior for better consitency due to changes in Time
calculation results in FileMaker over the last few Versions (8-11).
- Fixed bug, reported by Will Loving: in 24 hr mode, "4:23 PM" time returned "4:23 PM"
rather than the expected "16:23:00".
- Tweaked Behavior to better handle valid Filemaker times like 11:65:65, to add extra
overage amounts of lesser time parts to their higher counter parts correctly, to
make it a clock-compatible time.
- Made separator between AM/PM and time a variable for easy output tweaking.

Modification Date: 12/3/2012
- Escaped blank theTime input, was defaulting to 12AM.
- Fixed input parameter name not being correctly placed into theTime, variable.
- Renamed Time Input from timeField to theTime, since it doesn't require a field to use.

NOTE: Due to changes in the way FileMaker handles Time in calculations, there may be circumstances where you will find it difficult to get FileMaker to "display" the time as you intended. This calc will help, and in most cases it is all you need -- but if you are having problems, try looking at the custom function's results in the data viewer, or a text field, to see the actual results, rather than a time field.

This function formats any valid FileMaker Pro time value by the format specified in the function's parameter allowing the user to convert from any time format to 12 or 24 hour time. This is useful because calculated time data results are always returned in FileMaker Pro's native "24 hour" time format.

As of version 7, this is compatible with Set Field, where previous versions were limited to using a Paste Result [calculated].

Though "Field Formatting" on a layout can format the time data in a nice 12 hour format when viewed onscreen, the nicely presented time reveals it's true 24 hour nature if a user clicks into the field (they will see "0:30" instead of "12:30 AM"). In the case of our the example above, any 12 hour formatted value lists will also fail to "open scrolled to" the proper "12:30 AM" value.

You can return a specific Time format if you wrap any time calculations you use with this function and you will know the user will see "nice 12 hour" time, this also works nicely on time fields with Auto-Enter and overwrite existing values set to "on".

Some changes to the AM/PM variables or other formatting options within the function may be necessary to make this compatible with other language/time settings for solutions run on systems that do not use U.S. 12-hour time formatting.

This function is not designed to espouse 12 hour time over 24 (or Military Time), but many users are disconcerted when data appears to have "lost its formatting," just because the system performed a calculation upon it.


theTime - The time value to convert. The function only needs a time that is recognized by FileMaker Pro, and does not have to be the opposite of the desired converted result. (Thus if you are converting to 12 hour you *do not have to* provide a 24 hour formatted time.

type12or24 - The desired time format of the time result. The expected values are either 12 or 24, the default method is 12 Hour. Null or any value less than 24 will default to return a 12 hour time result .

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

This is my Custom Function and I want to edit it


5 most recent comments | Show all 15 comments

Thanks Jason, I missed that documentation change. The comment now matches the function parameter name.

Jonathan, Van Nuys, CA
January 22, 2013 5:56pm

Is there a way to suppress the seconds from the output? To be quite honest, I'm being a bit lazy and haven't read through the code in the script. I'm merely looking for an easy way to take a time field and output it in a 12 hour format.

Tom, Leland, NC
October 01, 2015 12:57pm

Yes Tom, for the 12 hour time it's a little easier to do. Towards the bottom of the calculation you will see a Result12 variable... Towards the end of the case statements found inside that variable, you'll see the seconds section, which you can delete or modify with a variable to make it optional.

Hope that helps!

Jonathan Mickelson, Los Angeles
October 01, 2015 10:04pm

Thanks and sorry for being lazy. I've been swamped and took the easy way out. Have a great weekend!

Tom, Leland, NC
October 02, 2015 12:49pm

If you do things incrementally...and MUST be able to create schedules and show BOTH or EITHER US or MILITARY for various items....

Format the field for TIME.
in Inspector Choose DATA and Format TIME as ENTERED.

Use a drop down menu for various times of the day US and MILITARY included in dropdown list.

Drop Down menu example in 15 min increments:


01:0 0am


For our purposes during work daylight hours..first common used 12 hours are listed in a drop down.


listed all the way to...



We don't change up schedules so quickly we do everythign in 15 min we use 15 min.

For MILITARY...during work hours..I created more time options JUST BELOW the handle the afternoon I add to my dropdown list to cover the afternoon hours....

13:30 go up to 7pm or 19:00


It takes a bit to make the drop down list complete..but the beauty of it is you can copy the time and paste it in another time field...and it keeps that time at the same spot in the dropdown you when you pull are already in the spot on the list in the time frame you are working for incremental additional or adding time slots...its easy and fast.

No issues with scripts, triggers...formatting..etc...Sort order works..Ascending.

Kimbakat, NYC
October 12, 2017 10:40am

Make a comment about this Custom Function (please try to keep it brief & to the point). Anyone can post:

Your Name:
characters left. If you paste in more than 1500 characters, it will be truncated. Discuss the function - advertisements and other useless posts will be deleted.
Answer 3 + 7 =
Search for Custom Functions:

Custom Functions Widget
Download the Custom Function Dashboard Widget for OS X
Keep all the latest Custom Functions right at your fingertips!

Newest Custom Functions:

1. SortList ( theList )
  (Sat, Jun 23, 8:45am)
2. HexUUIDToNum_cf (_uuid)
  (Sat, Jun 16, 1:55pm)
3. httpResponseCode ( responseHeaders )
  (Tue, Jun 12, 10:40pm)
4. FindDuplicateCharacters ( string )
  (Fri, Jun 08, 5:01pm)
5. FieldRepetitionLast ( field ; maxRepetition )
  (Wed, Jun 06, 6:05pm)
6. CountModifiedRecords ( NameTimestampField ; StartTimestamp ; EndTimestamp )
  (Mon, May 28, 8:23am)
7. JSONArrayLength ( JSONArrayStr )
  (Fri, May 25, 7:46am)
8. interpolation (y1; y2; y3; x1; x2; x3; x1y1; x2y1; x1y2; x2y2; rnd)
  (Sat, May 19, 3:55am)

RSS Feed of Custom Functions