### Title

Rounding times...

### Post

Hello,

I'm trying to set up a calculation field that will output a time rounded up to the next minute. The time is expressed in 24 hour format. The if the seconds go into the next minute, it is always rounded to the next minute.

from 12:01:01 -> 12:01:59 would equal 12:02:00

Any ideas?

Thanks in advance.

-Geoff

Time is stored in FileMaker as an integer that records time in seconds. That's why you can subtract two time fields and get the elapsed time in seconds without doing any special conversion operations. The time you see in hours, minutes and seconds is just special formatting used to make the internally stored integer a value that is intelligible to humans. Date fields work in much the same fashion, but mark time in days instead of seconds.

The time function allows you to create that internally stored integer from specified values for the hour, minute and second. that's what you are seeing in the calculation window. It's identifying what value to put in each "parameter" for the time function. 4:00:00 am could be returned by this function if you used: Time ( 4 ; 0 ; 0 ).

If you look up time functions in help, you'll find that the Hour(), Minute() and Second () functions extract just that portion of the value from a time field. In our case, Hour is being used to extract the hours and Minute is being used to extract the minutes from a given value in a time field. Since you want seconds to be 0, the seconds parameter is just that, 0. The only adjustment we need to do is to add one to minutes if there are any seconds recorded in this time field. That's where + (Seconds (T) > 0 ) comes in. If Seconds ( T ) returns any value greater than 0, this expression evaluates as "true". This is called a boolean value and a boolean value of true is the same as a 1. In FileMaker, 0 or an empty value are the same as False. Thus, this expression adds one if there are any seconds and adds zero if there aren't.