title: Rounding a DATETIME value in MySQL to nearest minute
body: <p>I have a DATETIME column in a table <code>t</code> with values like:</p>
  
  <pre><code>|toStampActual      |
  |-------------------|
  |2014-09-09 13:00:00|
  |2014-09-09 13:15:03|
  |2014-09-09 13:14:55|
  </code></pre>
  
  <p>I need to be able to update those value to:</p>
  
  <pre><code>|toStampActual      |
  |-------------------|
  |2014-09-09 13:00:00|
  |2014-09-09 13:15:00|
  |2014-09-09 13:15:00|
  </code></pre>
  
  <p>Basically round to nearest minute...anything greater than :30 seconds goes up, anything less goes down.</p>
  
  <p>I've found this answer <a href="https://stackoverflow.com/a/19291128/99401">https://stackoverflow.com/a/19291128/99401</a> and changed the SQL to </p>
  
  <pre><code>SELECT TIME_FORMAT(
      SEC_TO_TIME(
          (TIME_TO_SEC(toStampActual) DIV 60) * 60
      ), '%H:%i:%s') AS rounded_time 
  FROM `t`
  </code></pre>
  
  <p><a href="http://sqlfiddle.com/#!2/9af73/2/0" rel="nofollow noreferrer">SQL Fiddle</a></p>
  
  <p>But this only rounds down.  How can I round up or down based on the seconds?</p>