I want to update the datetime round to 15 minutes in a MYSQL database table.
For Example:
If the dateTime is 2013-10-08 10:36:00
, I want to conv
Use the same method as in the question you linked, but use UNIX_TIMESTAMP
functions instead. This will round either down or up to the nearest 15 minutes, remove the + 450
part if you want to round only down.
mysql> select FROM_UNIXTIME(((UNIX_TIMESTAMP('2013-08-07 12:05') + 450) DIV 900) * 900) AS roundtime;
+---------------------+
| roundtime |
+---------------------+
| 2013-08-07 12:00:00 |
+---------------------+