Software Venture Consulting

FileMaker Pro downloads & Resources
FileMaker Custom Functions
FileMaker Web Viewer Examples
FileMaker Pro & Lasso Consulting
Training
FileMaker Books
FileMaker Articles
FileMaker Error Reference

Free Web Tools
Free FileMaker Tools

Personal Pages
Videos
Adventures
Links

Shopping Cart
Shopping Cart

Search:

Free Newsletter
Signup


Contact


Privacy Policy



FileMaker is a registered trademark of FileMaker, Inc. in the U.S. and other countries.

 

 FileMaker Pro Custom Functions

List  |  Show Random  |  Upload  |  Add This to Your Site

ElapsedTime ( TStampBegin; TStampEnd; Format )

Rate this function:  

RatingRatingRatingRatingRating
  Average rating: 4.4  (30 votes)
  Discuss this Custom Function

Geoff Wells, DataIsland Software LLC
http://www.dataisland.com

Calculates elapsed time from Timestamps

Sample Input:
ElapsedTime ( Timestamp ( "5/17/2004" ; "8:45:25 PM" ) ; Timestamp ( "5/18/2004" ;" 10:46:45 PM" ); "String" )
Sample Output:
1 day, 2 hours, 1 minute, 20 seconds.


 Then copy & paste into FileMaker Advanced's Edit Custom Function window.

Click here to copy To Clip Manager if you have myFMbutler's Clip Manager installed

Description:

Calculates the elapsed time between two Timestamps and presents the results in several selectable formats.

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

This is my Custom Function and I want to edit it

Discuss:

5 most recent comments | Show all 9 comments

Revised the above additional code, so that the "ShortString" format shows NO periods with zeros, so that "0 days, 1 hour, 3 minutes, 0 seconds." now displays as "1 hour, 3 minutes."

Additionally, I added the format "TinyString" to display abbreviated time periods. So, "1 hr, 3 mins, 45 secs." with the same above feature tha NO periods display with zeros.

The new code is in my next comment...

John Davis, Houston
July 07, 2015 6:27am

Place the following code directly after the Format="String" block of code:

;

Format = "ShortString" or Format = "TinyString" ;
// Result is a string of actual duration elements with no zero elements displayed (e.g., no 0 minutes, 0 seconds, etc.)
// TinyString additionally displays abbreviated periods (e.g., 3 mins, 1 sec.)
Let ([

DAYS.ISSET = If ( Days ; True ; False );
HRS.ISSET = If ( Hours ; True ; False );
MINS.ISSET = If ( Minutes ; True ; False );
SECS.ISSET = If ( Seconds ; True ; False );
HRS.PERIOD.DISP = If ( Hours ; If ( Format = "TinyString" ; "hr" ; "hour" ) ; "" );
MINS.PERIOD.DISP = If ( Minutes ; If ( Format = "TinyString" ; "min" ; "minute" ) ; "" );
SECS.PERIOD.DISP = If ( Seconds ; If ( Format = "TinyString" ; "sec" ; "seconds" ) ; "" );
DAYS.POSSESSION = If ( Days > 1 ; "s" ; "" );
HRS.POSSESSION = If ( Hours > 1 ; "s" ; "" );
MINS.POSSESSION = If ( Minutes > 1 ; "s" ; "" );
SECS.POSSESSION = If ( Seconds > 1 ; "s" ; "" );
DAYS.PUNCT.AFT = If ( HRS.ISSET or MINS.ISSET or SECS.ISSET ; ", " ; "." );
HRS.PUNCT.AFT = If ( MINS.ISSET or SECS.ISSET ; ", " ; "." );
MINS.PUNCT.AFT = If ( SECS.ISSET ; ", " ; "." )

];

If ( DAYS.ISSET ; Days & " day" & DAYS.POSSESSION & DAYS.PUNCT.AFT ; "" ) & If ( HRS.ISSET ; Hours & " " & HRS.PERIOD.DISP & HRS.POSSESSION & HRS.PUNCT.AFT ; "" ) & If ( MINS.ISSET ; Minute

John Davis, Houston
July 07, 2015 6:35am

The final IF statement code got cutoff in the comment above. Replace the above final IF statement with this code:

If ( DAYS.ISSET ; Days & " day" & DAYS.POSSESSION & DAYS.PUNCT.AFT ; "" ) & If ( HRS.ISSET ; Hours & " " & HRS.PERIOD.DISP & HRS.POSSESSION & HRS.PUNCT.AFT ; "" ) & If ( MINS.ISSET ; Minutes & " " & MINS.PERIOD.DISP & MINS.POSSESSION & MINS.PUNCT.AFT ; "" ) & If ( SECS.ISSET ; Seconds & " " & SECS.PERIOD.DISP & SECS.POSSESSION & "." ; "" )
)

John Davis, Houston
July 07, 2015 6:38am

Fix in the code given 2 comments up. The line:

SECS.PERIOD.DISP = If ( Seconds ; If ( Format = "TinyString" ; "sec" ; "seconds" ) ; "" );

should be:

SECS.PERIOD.DISP = If ( Seconds ; If ( Format = "TinyString" ; "sec" ; "second" ) ; "" );

The change in the line is that the plural "seconds" should be the singular "second".

John Davis, Houston
July 07, 2015 9:41am

I can't seem to put the 'ShortString' in the right place for it to work. I put it before the very last of the original code.

HERE
)
)

it 'takes' it but it doesn't work. any help is appreciated

Troy Krueger, Greenwood Lake
August 29, 2016 6:47pm

Make a comment about this Custom Function (please try to keep it brief & to the point). Anyone can post:

Your Name:
City/Location:
Comment:
characters left. If you paste in more than 1500 characters, it will be truncated. Discuss the function - advertisements and other useless posts will be deleted.
Answer 3 + 6 =
Search for Custom Functions:

Custom Functions Widget
Download the Custom Function Dashboard Widget for OS X
Keep all the latest Custom Functions right at your fingertips!

Newest Custom Functions:

1. ProperAllWords ( text )
  (Thu, Dec 14, 5:19pm)
2. MatchExist ( SourceTable.Field ; DestTable.Field ; ReturnField )
  (Thu, Dec 14, 1:07pm)
3. BVR_Format ( bvr )
  (Wed, Dec 13, 5:32pm)
4. NumberToHexadecimal(NumberValue)
  (Fri, Dec 08, 8:54am)
5. Get_BaseTable
  (Thu, Dec 07, 4:27pm)
6. JSONCreateVarsFromKeys ( json ; namespace )
  (Wed, Dec 06, 8:21pm)
7. GetTableNzme ( field )
  (Tue, Dec 05, 9:16pm)
8. TimeFormatAsText ( theTime )
  (Mon, Nov 13, 1:59pm)

RSS Feed of Custom Functions