Clock in/out round to the nearest quarter hour

  • 0
  • 1
  • Question
  • Updated 1 year ago
  • Answered
I have added time card functionality in my application using the Essentials Employee Clock In/Clock Out app as a reference. I have the time cards working really well but I was wondering if there was a way to round the time in/out to the nearest quarter hour? I don't want our payroll person to have to deal with a clock in of 8:23am. Instead I would like 8:23am to get rounded up to 8:30am with 8:22am being rounded down to 8:15am
Photo of Justin Pauga

Justin Pauga

  • 390 Points 250 badge 2x thumb

Posted 1 year ago

  • 0
  • 1
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,634 Points 50k badge 2x thumb
Try this

var duration RoundedDurationFromMidnight =

Round([My Time Of Day Field] - ToTimeOfDay("12:00 am"), Minutes(15));

ToTimeOfDay("12:00 am") + $RoundedDurationFromMidnight



I had a look and the Round function will round durations, but not a TimeOfDay field.

So, my cheat is to change the time of day into the duration from Midnight, and round that Duration.  But now we have a duration and we need a TimeOfDay.  So then I add that Duration to midnight,  to get back to the Time Of Day rounded.
Photo of Justin Pauga

Justin Pauga

  • 390 Points 250 badge 2x thumb
Awesome, this worked great!
In case anyone runs into this issue as well, if the [My Time Of Day Field] is a date/time like mine is then you have to use the ToTimeOfDay function on that as well so your formula would look like: 

var duration RoundedDurationFromMidnight =

Round(ToTimeOfDay([My Time Of Day Field]) - ToTimeOfDay("12:00 am"), Minutes(15));

ToTimeOfDay("12:00 am") + $RoundedDurationFromMidnight