Round Time to next half-hour

Hey Guys!

So, I studied a lot about day and time maths with some great explanations here in the forum but, after some hours of trying I still don’t found a solution for this:

Any idea how can I get the current daytime, add 60min (one hour), and ROUND it to the next 30 minutes?
Here some examples:
10:23 become 11:30 (one more hour and next rounded half hour)
10:37 become noon (again, one more hour and next round half-hour)

It’s for a create schedule page, where I want to show options that start with a minimum of one hour from now, the options will have 30 minutes between them.

I know how to create the list of options and everything else is working fine, but I need to make this time math. Can someone help me with it? Thanks!

Hey @karimoo and @Victor I know you guys rock in this subject, if you can help me with it, will be very much appreciated!

Hi @brunoribeiro,

What comes to my mind:

  1. set “resulting time”: add 1hr29 to the current time (add 1/24/60*89)
    – there is no “RoundUP” function in Adalo, so I think adding 1hr 29 mins and rounding it down should work: 10:30 + 1:29 = 11:59 → 11:30; 10:23 + 1:29 = 11:42 → 11:30; 10:31 + 1:29 = 12:00 → 12:00.
  2. get the integer & fractional part of the resulting time
  3. multiple fractional part by 48
    – we’ll get “half-hours” as integers here
  4. take INT out of the fractional part
  5. divide the result by 48
    – back to “part of the day”
  6. add this result to the integer part of the resulting time (from step 2)

I didn’t try it in the app - this is pure theory. Will check later if it works :slight_smile:

Best,
Victor.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.