Round minutes for the time picker

Hello everyone!

I am using Grafana 10.0.0 in Windows

In the time picker. When I select Today or Today so for, it is starting the panel series at 00:00 and then 00:01 or 00:10 depending on the time interval. But, if I select the last 30 minutes, it is going to 00:01:03, 00:06:03 and so on when the time interval is 5 minutes here.

I would like to know if there is any way to round up the starting time to the closest minute and go from there instead of bringing the seconds into the mix.

Found the answer!

DECLARE @rounded_time_from DATETIME = DATEADD(MINUTE, DATEDIFF(MINUTE, 0, $__timeFrom()), 0);

DECLARE @rounded_time_to DATETIME = DATEADD(MINUTE, DATEDIFF(MINUTE, 0, $__timeTo()), 0);

1 Like