Brian Dunning's FileMaker Custom Functions

SubtractTimes ( Time1 ; Time2 )

Subtract one time from another; both times in h:mm:ss format

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

Bill Thurmes   Bill Thurmes - Show more from this author
MDCA
http://www.miyotadca.com

Share on Facebook Share on Twitter

  Sample input:
SubtractTimes ( "59:43" ; "28:13" )
SubtractTimes ( "2:01:58" ; "29:54" )
  Sample output:
31:30
1:32:04

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

Time2 will be subtracted from Time1
Entry format should be h:mm:ss, or mm:ss, or ss.
Result will be in same format, dropping unneeded info from left.
Primarily useful if data is/might be in a mm:ss format
It now gives the correct answer if Time1 is earlier than Time2
Changed 4/12/19 to work better

 

Comments

comment   comment, VR
Apr 10, 2014
Filemaker can add and subtract times natively.
 
Bill Thurmes   Bill Thurmes, MDCA
Apr 11, 2014
Thanks, VR. I had needed something to subtract text that was in a mm:ss format, which Filemaker's native time addition doesn't deal with well. I've changed the script to use Filemaker's native capabilities.
 
K.C.   K.C., San Francisco
Oct 17, 2014
Is there a way to accept non military time? If time 1 occurs before noon, and time 2 occurs after noon, the results are in the wrong direction.
 
Bill Thurmes   Bill Thurmes, MDCA
Oct 22, 2014
I assume you want a negative result when Time1 is before Time2? That it didn't work before was a bug in my function; in the final case statement I had forgotten to apply sign to t; I've fixed that now.
 

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: