Brian Dunning's FileMaker Custom Functions

FormatTime_NoSeconds ( a.time )

Formats a time to a consistent AM/PM without any seconds.

  Average rating: 4.5 (23 votes) Log in to vote

David Jondreau   David Jondreau - Show more from this author
Wing Forward Solutions, LLC
http://www.wingforward.net

Share on Facebook Share on Twitter

  Sample input:
FormatTime_NoSeconds ( "2:03:12 pm" )
  Sample output:
2:03 PM

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

Time fields are a little funny. They store what is entered. So you can put in 1 PM or 2:31:03 am and that's what it will store. You can change what a field displays as using the formatting options, but when you click into a field it shows what is being stored. And you'll need to remember to format any output if you want a consistent look.

Often, the seconds column are unnecessary.

This function takes a time field (entered in US format, not military time), removes the seconds, and formats it so the same style of time will be stored.

 

Comments

comment   comment, VR
Apr 8, 2015
1. Your formula breaks on an undefined function(?) Null.

2. Couldn't this be simpler? For example:

Mod ( Hour ( time ) - 1 ; 12 ) + 1 & SerialIncrement ( ":00" ; Minute ( time ) ) & Case ( time < 43200 ; " AM" ; " PM" )

seems to return the same results as yours would. Note that both fail with times greater than 24 hours (25:00:00 is 1:00 AM, not PM), but that's easy (at least in my version) to fix.
 

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: