Brian Dunning's FileMaker Custom Functions

RoundTime ( time ; duration ; up )

Rounds a time to a given duration, up or down.

  Average rating: 4.3 (33 votes) Log in to vote

Kieren MacMillan   Kieren MacMillan
kierencom
http://www.kierencom.ca

Share on Facebook Share on Twitter

  Sample input:
RoundTime ( GetAsTime ( "10:38:36" ) ; GetAsTime ( "0:15:00" ) ; 1 )
  Sample output:
10:45:00

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

This function rounds a given time to a given duration, taking advantage of the fact that FMP stores times as an integer number (seconds). [Note: Though not strictly necessary, it is likely that the desired calculation result would be of type time.]

The 'up' parameter, which dictates rounding direction, should be either 1/true (up) or 0/false (down).

 

Comments

BBHH   BBHH, Hamburg
Dec 22, 2012
if you want to round up to 5 Minutes : RoundTime ( time ; 300 ; 1 )
and time is 00:05:00 you will get 10 minutes.
I think the right time should be 5 Minutes.

The improved formula is:

( Int ( (time-up) / duration ) + up ) * duration
 
BBHH   BBHH, Hamburg
Dec 22, 2012
if you want to round up to 5 Minutes : RoundTime ( time ; 300 ; 1 )
and time is 00:05:00 you will get 10 minutes.
I think the right time should be 5 Minutes.

UPDATE: And to get 0 Minutes for the time "00:00:00"

The improved formula is:
If (t_time = 0;0; ( Int ( (time-up) / duration ) + up ) * duration)
 

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.

Under construction. Email me your wish list for improvements.