title: MySQL SEC_TO_TIME gives hh:mm:ss.000000
body: <p>As said in the caption I am wondering why the <code>SEC_TO_TIME</code>-Function of MySQL gives me that Zeros at the end.</p>
  
  <p>Refering to the docu (<a href="http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_sec-to-time" rel="nofollow">http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_sec-to-time</a>) that shouldn't happen (I am using MySQL 5.0.11).</p>
  
  <p>Any Idea why this Zeros appears and how to get rid of them? To much zeros for displaying miliseconds.</p>
  
  <p>Sine the zeros doens't break MySQLs Date-funcions, it's more a <em>"I don't like that"</em>-Question rather than a real Problem (at least till now^^)</p>
  
  <p>// EDIT: I just figured out that the zeros aren't coming from the SEC_TO_TIME but from the FROM_UNIXTIME()-Function. Thx to @Abhik Chakraborty to ask for the input!</p>
  
  <p>// EDIT2: I used <code>FROM_UNIXTIME(last_try, '%Y-%m-%d %H:%i:%s')</code> to get rid of the zeros. But When I do <code>TIME(FROM_UNIXTIME(last_try, '%Y-%m-%d %H:%i:%s'))</code> the zeros are back. Why??</p>
  
  <p>Seems like every function adds the zeros back. Using <code>SEC_TO_TIME</code> on a simple integer-value also gives zeros...</p>
  
  <p>Here is the whole query iam using: </p>
  
  <pre><code>SELECT
      SEC_TO_TIME(FLOOR(TIME_TO_SEC((TIME(FROM_UNIXTIME(`last_try`))))/1800)*1800)
  FROM `last48h`
  </code></pre>
  
  <p>The query reads the timestamp, gets only the time, converts it to seconds, breaks the seconds into half-hours (/1800 gives 0 &lt; x &lt; 48) rounds down and converts back to time</p>