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  (31 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.

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 10 comments

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

Brilliant, totally brilliant.
Works a charm.
TinyString works Ok for me.
Geoff, you should be proud of yourself.

Alistair Hay, UK
January 07, 2018 1:59pm

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 0 + 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. HexUUIDToNum_cf (_uuid)
  (Sat, Jun 16, 1:55pm)
2. httpResponseCode ( responseHeaders )
  (Tue, Jun 12, 10:40pm)
3. FindDuplicateCharacters ( string )
  (Fri, Jun 08, 5:01pm)
4. FieldRepetitionLast ( field ; maxRepetition )
  (Wed, Jun 06, 6:05pm)
5. CountModifiedRecords ( NameTimestampField ; StartTimestamp ; EndTimestamp )
  (Mon, May 28, 8:23am)
6. JSONArrayLength ( JSONArrayStr )
  (Fri, May 25, 7:46am)
7. interpolation (y1; y2; y3; x1; x2; x3; x1y1; x2y1; x1y2; x2y2; rnd)
  (Sat, May 19, 3:55am)
8. @JSONFormatElements ( json )
  (Tue, May 15, 3:31am)

RSS Feed of Custom Functions