MySQL MICROSECOND Function

MySQL Microsecond Date Function will return the microseconds from the given time or DateTime expression, and the syntax is as shown below:

MICROSECOND(DateTime or time expression);

MySQL Microsecond function Example

These examples help you understand the use of this Microsecond function. Here, we are returning the Microseconds from the time expression, and the Date & time expression.

SELECT MICROSECOND('10:12:22.223156');

SELECT MICROSECOND('12:12:44.123160');

SELECT MICROSECOND('2019-02-14 10:12:22.223156');
MySQL MICROSECOND Example 1

Let us see another example of this Date method. In this MySQL exmaple, we are trying to return the Microseconds from the datetime returned by the Now(), and UTC_TIMESTAMP functions.

SELECT MICROSECOND(NOW());

SELECT MICROSECOND(UTC_TIMESTAMP());

SELECT MICROSECOND('12:12:62.123160');

From the below screenshot (’12:12:62.123160′), means we are trying to get a microsecond from an invalid date. That’s why MySQL returns NULL.

MICROSECOND Example 2