I have a DATETIME column in a table t
with values like:
|toStampActual |
|-------------------|
|2014-09-09 13:00:00|
|2014-09-09 13:15:03|
|2014-09-09 13:14:55|
I need to be able to update those value to:
|toStampActual |
|-------------------|
|2014-09-09 13:00:00|
|2014-09-09 13:15:00|
|2014-09-09 13:15:00|
Basically round to nearest minute...anything greater than :30 seconds goes up, anything less goes down.
I've found this answer https://stackoverflow.com/a/19291128/99401 and changed the SQL to
SELECT TIME_FORMAT(
SEC_TO_TIME(
(TIME_TO_SEC(toStampActual) DIV 60) * 60
), '%H:%i:%s') AS rounded_time
FROM `t`
But this only rounds down. How can I round up or down based on the seconds?