Round dezimal values for time entries

Hello, I would like to round up time entries to a full 15 minutes in a desktop app. This means that if a user enters 1.5 in a text field, it should result in 1.5. If he enters 1.6 then it should result in 1.75. If he enters 1.1 it should be 1.25. Only the decimal values x.00 / x.25 / x.50 and x.75 should be allowed and automatically rounded up to the next higher value. I hope I phrased that in a reasonably understandable way. Now my question, is there a simple solution for this? What’s the most elegant way to solve something like this? Many Thanks

Minutes = Ceil(minutes / 15) * 15

1 Like

Or in API2:

Minutes = Ceiling(minutes / 15) * 15

Thank you Greg. This works great when the input is minutes. However, in my case, the time entries are entered in the form 1.3. That would mean 1 hour and 18 minutes. So I would have to convert the entries into minutes and first split the values before the decimal point as hours and the decimal places as minutes. I came up with all sorts of possible solutions, but they all seemed too complicated to me. I’m assuming I’m just not thinking of the simple and obvious solution.


Minutes = Ceiling(minutes * 4) / 4

Your 1.3 * 4 → ceiling( 5.2 ) → 6 → 6 / 4 → 1.5


Hi Ian, this is the solution. I knew that I couldn’t see the forest for the trees! Thank you for saving me a lot of nerves.

For all beginners here is the method how I implement it now. This does exactly what I wanted to achieve.

//Round Time Values to full 15 minutes
Var time As Double
Var roundedTime As String
time = _time.ToDouble
time = Ceiling(time  * 4) / 4
roundedTime = time.ToString(Locale.Current)
Return roundedTime

Method signature:

round_timeentries(_time As String) As String

The method is called in the “FocusLost” Event of the Textfield like that:

me.Text = round_timeentries(me.Text)