Brian Dunning's FileMaker Custom Functions

DateFormatStrftime ( someTimeStamp ; formatString )

Format a date/timestamp using the format defined by the POSIX/UNIX 'strftime'

  Be the first to rate this function Log in to vote

Dan Shockley   Dan Shockley - Show more from this author

Share on Facebook Share on Twitter

  Sample input:
DateFormatStrftime ( "3/9/2023 4:57:00 PM" ; "%-m/%-d/%y" )
  Sample output:
"3/9/23"

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

There are a bunch of useful "format some date/timestamp" functions, but I've used this for a long time. But, it is also possible to just use a long-standing set of formatting codes defined long ago by the 'strftime' POSIX shell command built into UNIX. See https://manpages.org/strftime
Most of its formatting codes are supported - see the function's documentation.

There are a few special uses:
- If you send "Help" for the 1st param, you get usage instructions, which is good when you don't remember a formatting code.
- If you send "NOW" for the 1st param, it uses the CurrentHostTimestamp, along with your format string.
- If you send "File_NOW" for the 1st param, it uses the CurrentHostTimestamp and you can leave the formatString empty. It will format a timestamp that works within a filename on any OS platform (no slashes or colons), in an ISO8601-style format.
- If you send "File_AsNum_NOW" for the 1st param, it uses the CurrentHostTimestamp and you can leave the formatString empty. It will format a timestamp that works within a filename on any OS platform (no slashes or colons), but specifically with no punctuation, just numbers.
- If you send "File_AsDateLine_NOW" for the 1st param, it uses the CurrentHostTimestamp and you can leave the formatString empty. It will format a timestamp as a simple dateline like you'd see in a news article.
- If you send "File_Friendly_NOW" for the 1st param, it uses the CurrentHostTimestamp and you can leave the formatString empty. It will format a timestamp that works within a filename on any OS platform (no slashes or colons), in a human-friendly format.

 

Comments

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: