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
using unix_timestamp allows quite simpe arithmetic, change 15 in the code below to some other number if needed (such as 30)
select from_unixtime(round(unix_timestamp('2013-10-08 10:36:00')/(60*15))*(60*15));
= October, 08 2013 10:30:00+0000
select from_unixtime(round(unix_timestamp('2013-10-08 10:22:00')/(60*15))*(60*15));
= October, 08 2013 10:15:00+0000
see: http://forums.mysql.com/read.php?20,131939,201089#msg-201089