0

I'm trying to group timestamps into slots of 15 Minutes. I'm using the following sql statement to retrieve time data from my mysql database.

select
  floor(unix_timestamp(timestamp)/(15*60)) as "Time"
from Table;

That results in a table looking like this:

Time
1846513
1846515
...

The resulting timestamps are converted in grafana where I want to display certain panels.

When applying the time conversion option (transform > Convert field type > Field Time as Time) the timestamps are converted to a different timestamp than they're supposed to. The result looks like this:

Time
1970-01-01 01:30:46.513
1970-01-01 01:30:46.515
...

When only retrieving the timestamps (They come pre converted to datetime) using the following command

select
  timestamp as "Time"
from Table;

I get a result that looks like this:

Time
2022-08-30 16:16:07
...

How can I get the right time conversion?

Any help is appreciated. :)

1 Answers1

0

Don't forget to multiply back the 15*60 after you divide and use FLOOR().

15 * 60 * floor(unix_timestamp(timestamp)/(15*60))
O. Jones
  • 103,626
  • 17
  • 118
  • 172