Skip to content
Advertisement

Rounding script works to the nearest 15 minutes based on duration, how to shift this threshold by negative 30 seconds for decimal hours

I have a script which rounds a time length to the nearest 15 minutes. So for example 00:23:00 minutes to 00:37:59 duration will return 0.5 (decimal 30 minutes) etc continuous around the clock. I am trying to now get the script to work in half minutes so I need to shift this by 30 second offset for the rounding, so 00:22:29 seconds will go to 0.25 and 00:22:30 will round to 0.5. Here is the original script. So this needs to return 0.5 not 0.25. If you change the @finish to 08:22:29 it needs to then return 0.25. Thank you

Advertisement

Answer

Here’s another possible solution, using CASE to classify the modulo seconds over an hour:

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement