Brian Dunning's FileMaker Custom Functions

FormatTimestamp ( format ; tstamp )

Formats a time/date any way you like using a format string

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

Tim Mansour   Tim Mansour

Share on Facebook Share on Twitter

  Sample input:
FormatTimestamp ( "[Dayname] [D]-[MON]-[YY] [h].[mm][am]" , "" )
  Sample output:
Thursday 25-MAR-10 2.30pm

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

Formats a timestamp according to a format string, replacing date/time component placeholders with respective data. See the Substitute command in the function to determine (or change) the placeholders to use. Includes placeholders to allow upper/lower case for text components (eg, day names).
Use a null input timestamp ("") to format the current date/time.

 

Comments

simon Plint   simon Plint, Australia
Mar 24, 2010
hr12 = Mod ( h - 1; 12 ) + 1
should be
hr12 = Mod ( hr - 1; 12 ) + 1

["[am]"; If ( h < 12; "am"; "pm" )];
should be
["[am]"; If ( hr < 12; "am"; "pm" )];
 
Tim Mansour   Tim Mansour
Mar 24, 2010
I've updated the function to my latest version.
 
Kevin Smith   Kevin Smith, London
Jun 3, 2015
Watch out for when keying in the formatting parameters. The case of the parameter often controls the case of the output e.g. "[month]" vs "[MONTH]".

Here's an exception: The parameter "[mm]" generates minutes while the parameter "[MM]" generates months.
 

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.