andersonbd1
andersonbd1

Reputation: 5416

milliseconds in mysql

This page explains how to format milliseconds http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_now

but how do I get the actual millisecond value beyond just .00000?

I've tried these:

  select unix_timestamp()+0;
  select SYSDATE()+0;
  select date_format(now(), '%f');
  select now()+0;

but none of theme give me precise and accurate milliseconds

Upvotes: 4

Views: 11394

Answers (2)

AbD_Riz
AbD_Riz

Reputation: 435

If you want to get the microsecond from a field, use %f,

select FROM_UNIXTIME(DATE_COLUMN/1000,'%Y-%M-%d %H:%i:%s %f') from TABLE_NAME;

+-------------------------------------------------------+
| FROM_UNIXTIME(CREATETIME/1000,'%Y-%M-%d %H:%i:%s %f') |
+-------------------------------------------------------+
| 2016-March-18 16:02:54 342000                         |
+-------------------------------------------------------+

Source : MYSQL DATE_FORMAT

Upvotes: 1

adelarsq
adelarsq

Reputation: 3738

This is a bug from mysql http://bugs.mysql.com/bug.php?id=8523

Upvotes: 2

Related Questions