Brian Dunning's FileMaker Custom Functions

IsTimestamp ( _var )

return timestamp in number of seconds if valid or nothing if invalid

  Average rating: 4.7 (27 votes) Log in to vote

Rewolfer   Rewolfer - Show more from this author
http://rewolfer.de

Share on Facebook Share on Twitter

  Sample input:
IsTimestamp ( "2003-12-19 12:04:10" )
IsTimestamp ( "19.12.2003 12:04:10" )
IsTimestamp ( "12/19/2003 12:04:10" )
IsTimestamp ( "12/19/2003 1:04:10 PM" )
IsTimestamp ( "19/12/2003 12:04:10" )
  Sample output:
63207432250

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

/*=================================================

FORM: IsTimestamp ( _var )

PURPOSE: return timestamp in number of seconds if valid

PARAMETER: _var type: unknown value: unknown

RESULT: valid timestamp in seconds since 0001-01-01 00:00:00 or nothing if invalid

DEPENDENCY: IsDate() ; IsTimeOfDay()

NOTE: to import timestamps with different formats set the auto calculation of the timestamp field to "GetAsTimestamp ( IsTimestamp ( Self ))"
and it will convert the import format to the current setting
"11/23/2003 12:11" => "2003-11-23 12:11"
if you'd like to accept British timestamps read the note in IsDate()

EXAMPLE: IsTimestamp ( "19.12.2003 12:04:10" ) => 63207432250
IsTimestamp ( "12/19/2003 1:04:10 PM" ) => 63207432250
IsTimestamp ( "19.14.2003 12:04:10" ) => "" (invalid date)

HISTORY: 2012-04-16 [205814] 1.00 tsw outsourced timestamp validation
2012-04-19 [144827] 1.10 tsw cascaded casing to speed things up
2012-04-26 [080453] 1.20 tsw broader AM/PM-integration

DEVELOPER: tsw @ http://rewolfer.de

=================================================*/

 

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: