Alex Rivera | Logout

Group mysql query by 15 min intervals

Asked 2010-05-08T12:13:02.297
55

I've got a monitoring system that is collecting data every n seconds (n is approximately 10 but varies). I'd like to aggregate the collected data by 15 minute intervals. Is there a way to consolidate the timestamp values into 15 minute chunks to allow for grouping to work?

Edit
Report

1 Answer

1

This worked for me

mysql> **SELECT FROM_UNIXTIME(UNIX_TIMESTAMP(NOW())- UNIX_TIMESTAMP(NOW())%(15*60));**
+---------------------------------------------------------------------+
| FROM_UNIXTIME(UNIX_TIMESTAMP(NOW())- UNIX_TIMESTAMP(NOW())%(15*60)) |
+---------------------------------------------------------------------+
| 2012-02-09 11:15:00                                                 |
+---------------------------------------------------------------------+
1 row in set (0.00 sec)
answered 2012-02-09T16:23:49.353

Your Answer