How to retrieve microseconds or milliseconds from MySQL current time?

前端 未结 5 2142
天涯浪人
天涯浪人 2021-01-02 02:17

I am trying to create my first stored function on MySQL. In this function I want to return the timestamp of the current date and time with 3 microsecond digits like this:

5条回答
  •  温柔的废话
    2021-01-02 02:53

    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.

提交回复
热议问题