How to retrieve microseconds or milliseconds from MySQL current time? How to retrieve microseconds or milliseconds from MySQL current time? mysql mysql

How to retrieve microseconds or milliseconds from MySQL current time?


MySQL 5.6 supports the millisecond precision in the sysdate function.

try

select sysdate(6) will return 2013-04-16 13:47:56.273434

and

select sysdate(3) will return 2013-04-16 13:47:56.273


Take a look at what MySQL says(http://dev.mysql.com/doc/refman/5.1/en/fractional-seconds.html):

However, when MySQL stores a value into a column of any temporal data type, it discards any fractional part and does not store it.

So you need to store it not as a date value, but as a simple floating point value.


For mysql 5.6

round(unix_timestamp() * 1000  + MICROSECOND(sysdate(6)) / 1000)